Server IP : 92.205.26.207 / Your IP : 216.73.216.16 Web Server : Apache System : Linux 207.26.205.92.host.secureserver.net 4.18.0-553.60.1.el8_10.x86_64 #1 SMP Thu Jul 10 04:01:16 EDT 2025 x86_64 User : zikryat ( 1002) PHP Version : 8.3.23 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/zikryat/public_html/node_modules/mongodb/lib/operations/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RenameOperation = void 0; const collection_1 = require("../collection"); const error_1 = require("../error"); const utils_1 = require("../utils"); const operation_1 = require("./operation"); const run_command_1 = require("./run_command"); /** @internal */ class RenameOperation extends run_command_1.RunAdminCommandOperation { constructor(collection, newName, options) { // Check the collection name (0, utils_1.checkCollectionName)(newName); // Build the command const renameCollection = collection.namespace; const toCollection = collection.s.namespace.withCollection(newName).toString(); const dropTarget = typeof options.dropTarget === 'boolean' ? options.dropTarget : false; const cmd = { renameCollection: renameCollection, to: toCollection, dropTarget: dropTarget }; super(collection, cmd, options); this.options = options; this.collection = collection; this.newName = newName; } execute(server, session, callback) { const coll = this.collection; super.execute(server, session, (err, doc) => { if (err) return callback(err); // We have an error if (doc?.errmsg) { return callback(new error_1.MongoServerError(doc)); } let newColl; try { newColl = new collection_1.Collection(coll.s.db, this.newName, coll.s.options); } catch (err) { return callback(err); } return callback(undefined, newColl); }); } } exports.RenameOperation = RenameOperation; (0, operation_1.defineAspects)(RenameOperation, [operation_1.Aspect.WRITE_OPERATION]); //# sourceMappingURL=rename.js.map