UNPKG

mongodb-rag-core

Version:

Common elements used by MongoDB Chatbot Framework components.

52 lines 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isNonMutativeOperation = exports.JS_MUTATIVE_METHODS = void 0; /** Default list of mutative MongoDB methods. */ exports.JS_MUTATIVE_METHODS = [ // Document insertion methods "insertOne", "insertMany", "insert", // Document update methods "updateOne", "updateMany", "update", "replaceOne", "findOneAndUpdate", "findOneAndReplace", "findAndModify", "save", "upsert", // Document deletion methods "deleteOne", "deleteMany", "remove", "findOneAndDelete", "findOneAndRemove", // Collection methods that modify data "drop", "createIndex", "createIndexes", "dropIndex", "dropIndexes", // Database methods that modify data "dropDatabase", "renameCollection", // Bulk operations "bulkWrite", ]; /** Checks if the given methods are mutative. */ function isNonMutativeOperation(methods, mutativeMethods = exports.JS_MUTATIVE_METHODS) { // If methods is undefined or empty, consider it safe if (!methods || methods.length === 0) { return true; } // Check if any of the methods are in the mutative list return !methods.some((method) => mutativeMethods.includes(method)); } exports.isNonMutativeOperation = isNonMutativeOperation; //# sourceMappingURL=isNonMutativeOperation.js.map