mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-24 01:29:19 +02:00
some progress
This commit is contained in:
parent
aea93a5527
commit
e3c15bd288
1388 changed files with 306946 additions and 68323 deletions
74
node_modules/mongodb/lib/operations/add_user.js
generated
vendored
Normal file
74
node_modules/mongodb/lib/operations/add_user.js
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AddUserOperation = void 0;
|
||||
const crypto = require("crypto");
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class AddUserOperation extends command_1.CommandOperation {
|
||||
constructor(db, username, password, options) {
|
||||
super(db, options);
|
||||
this.db = db;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.options = options ?? {};
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const db = this.db;
|
||||
const username = this.username;
|
||||
const password = this.password;
|
||||
const options = this.options;
|
||||
// Error out if digestPassword set
|
||||
// v5 removed the digestPassword option from AddUserOptions but we still want to throw
|
||||
// an error when digestPassword is provided.
|
||||
if ('digestPassword' in options && options.digestPassword != null) {
|
||||
return callback(new error_1.MongoInvalidArgumentError('Option "digestPassword" not supported via addUser, use db.command(...) instead'));
|
||||
}
|
||||
let roles;
|
||||
if (!options.roles || (Array.isArray(options.roles) && options.roles.length === 0)) {
|
||||
(0, utils_1.emitWarningOnce)('Creating a user without roles is deprecated. Defaults to "root" if db is "admin" or "dbOwner" otherwise');
|
||||
if (db.databaseName.toLowerCase() === 'admin') {
|
||||
roles = ['root'];
|
||||
}
|
||||
else {
|
||||
roles = ['dbOwner'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
roles = Array.isArray(options.roles) ? options.roles : [options.roles];
|
||||
}
|
||||
let topology;
|
||||
try {
|
||||
topology = (0, utils_1.getTopology)(db);
|
||||
}
|
||||
catch (error) {
|
||||
return callback(error);
|
||||
}
|
||||
const digestPassword = topology.lastHello().maxWireVersion >= 7;
|
||||
let userPassword = password;
|
||||
if (!digestPassword) {
|
||||
// Use node md5 generator
|
||||
const md5 = crypto.createHash('md5');
|
||||
// Generate keys used for authentication
|
||||
md5.update(`${username}:mongo:${password}`);
|
||||
userPassword = md5.digest('hex');
|
||||
}
|
||||
// Build the command to execute
|
||||
const command = {
|
||||
createUser: username,
|
||||
customData: options.customData || {},
|
||||
roles: roles,
|
||||
digestPassword
|
||||
};
|
||||
// No password
|
||||
if (typeof password === 'string') {
|
||||
command.pwd = userPassword;
|
||||
}
|
||||
super.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.AddUserOperation = AddUserOperation;
|
||||
(0, operation_1.defineAspects)(AddUserOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=add_user.js.map
|
||||
1
node_modules/mongodb/lib/operations/add_user.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/add_user.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"add_user.js","sourceRoot":"","sources":["../../src/operations/add_user.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAIjC,oCAAqD;AAGrD,oCAAkE;AAClE,uCAAsE;AACtE,2CAAoD;AAqBpD,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,0BAA0B;IAM9D,YAAY,EAAM,EAAE,QAAgB,EAAE,QAA4B,EAAE,OAAwB;QAC1F,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IAC/B,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA4B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GAAG,QAAQ,CAAC;QAE5B,IAAI,CAAC,cAAc,EAAE;YACnB,yBAAyB;YACzB,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACrC,wCAAwC;YACxC,GAAG,CAAC,MAAM,CAAC,GAAG,QAAQ,UAAU,QAAQ,EAAE,CAAC,CAAC;YAC5C,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAClC;QAED,+BAA+B;QAC/B,MAAM,OAAO,GAAa;YACxB,UAAU,EAAE,QAAQ;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;YACpC,KAAK,EAAE,KAAK;YACZ,cAAc;SACf,CAAC;QAEF,cAAc;QACd,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,OAAO,CAAC,GAAG,GAAG,YAAY,CAAC;SAC5B;QAED,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF;AApFD,4CAoFC;AAED,IAAA,yBAAa,EAAC,gBAAgB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
91
node_modules/mongodb/lib/operations/aggregate.js
generated
vendored
Normal file
91
node_modules/mongodb/lib/operations/aggregate.js
generated
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AggregateOperation = exports.DB_AGGREGATE_COLLECTION = void 0;
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
exports.DB_AGGREGATE_COLLECTION = 1;
|
||||
const MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT = 8;
|
||||
/** @internal */
|
||||
class AggregateOperation extends command_1.CommandOperation {
|
||||
constructor(ns, pipeline, options) {
|
||||
super(undefined, { ...options, dbName: ns.db });
|
||||
this.options = { ...options };
|
||||
// Covers when ns.collection is null, undefined or the empty string, use DB_AGGREGATE_COLLECTION
|
||||
this.target = ns.collection || exports.DB_AGGREGATE_COLLECTION;
|
||||
this.pipeline = pipeline;
|
||||
// determine if we have a write stage, override read preference if so
|
||||
this.hasWriteStage = false;
|
||||
if (typeof options?.out === 'string') {
|
||||
this.pipeline = this.pipeline.concat({ $out: options.out });
|
||||
this.hasWriteStage = true;
|
||||
}
|
||||
else if (pipeline.length > 0) {
|
||||
const finalStage = pipeline[pipeline.length - 1];
|
||||
if (finalStage.$out || finalStage.$merge) {
|
||||
this.hasWriteStage = true;
|
||||
}
|
||||
}
|
||||
if (this.hasWriteStage) {
|
||||
this.trySecondaryWrite = true;
|
||||
}
|
||||
else {
|
||||
delete this.options.writeConcern;
|
||||
}
|
||||
if (this.explain && this.writeConcern) {
|
||||
throw new error_1.MongoInvalidArgumentError('Option "explain" cannot be used on an aggregate call with writeConcern');
|
||||
}
|
||||
if (options?.cursor != null && typeof options.cursor !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Cursor options must be an object');
|
||||
}
|
||||
}
|
||||
get canRetryRead() {
|
||||
return !this.hasWriteStage;
|
||||
}
|
||||
addToPipeline(stage) {
|
||||
this.pipeline.push(stage);
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const options = this.options;
|
||||
const serverWireVersion = (0, utils_1.maxWireVersion)(server);
|
||||
const command = { aggregate: this.target, pipeline: this.pipeline };
|
||||
if (this.hasWriteStage && serverWireVersion < MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT) {
|
||||
this.readConcern = undefined;
|
||||
}
|
||||
if (this.hasWriteStage && this.writeConcern) {
|
||||
Object.assign(command, { writeConcern: this.writeConcern });
|
||||
}
|
||||
if (options.bypassDocumentValidation === true) {
|
||||
command.bypassDocumentValidation = options.bypassDocumentValidation;
|
||||
}
|
||||
if (typeof options.allowDiskUse === 'boolean') {
|
||||
command.allowDiskUse = options.allowDiskUse;
|
||||
}
|
||||
if (options.hint) {
|
||||
command.hint = options.hint;
|
||||
}
|
||||
if (options.let) {
|
||||
command.let = options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
command.cursor = options.cursor || {};
|
||||
if (options.batchSize && !this.hasWriteStage) {
|
||||
command.cursor.batchSize = options.batchSize;
|
||||
}
|
||||
super.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.AggregateOperation = AggregateOperation;
|
||||
(0, operation_1.defineAspects)(AggregateOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING
|
||||
]);
|
||||
//# sourceMappingURL=aggregate.js.map
|
||||
1
node_modules/mongodb/lib/operations/aggregate.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/aggregate.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"aggregate.js","sourceRoot":"","sources":["../../src/operations/aggregate.ts"],"names":[],"mappings":";;;AACA,oCAAqD;AAGrD,oCAAsE;AACtE,uCAAwF;AACxF,2CAA0D;AAE1D,gBAAgB;AACH,QAAA,uBAAuB,GAAG,CAAU,CAAC;AAClD,MAAM,0CAA0C,GAAG,CAAU,CAAC;AA0B9D,gBAAgB;AAChB,MAAa,kBAAiC,SAAQ,0BAAmB;IAMvE,YAAY,EAAoB,EAAE,QAAoB,EAAE,OAA0B;QAChF,KAAK,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAEhD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAE9B,gGAAgG;QAChG,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C,aAAa,EAAE;YAC5C,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;SAC9C;QAED,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF;AAnGD,gDAmGC;AAED,IAAA,yBAAa,EAAC,kBAAkB,EAAE;IAChC,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,eAAe;CACvB,CAAC,CAAC"}
|
||||
36
node_modules/mongodb/lib/operations/bulk_write.js
generated
vendored
Normal file
36
node_modules/mongodb/lib/operations/bulk_write.js
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BulkWriteOperation = void 0;
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class BulkWriteOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, operations, options) {
|
||||
super(options);
|
||||
this.options = options;
|
||||
this.collection = collection;
|
||||
this.operations = operations;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const coll = this.collection;
|
||||
const operations = this.operations;
|
||||
const options = { ...this.options, ...this.bsonOptions, readPreference: this.readPreference };
|
||||
// Create the bulk operation
|
||||
const bulk = options.ordered === false
|
||||
? coll.initializeUnorderedBulkOp(options)
|
||||
: coll.initializeOrderedBulkOp(options);
|
||||
// for each op go through and add to the bulk
|
||||
try {
|
||||
for (let i = 0; i < operations.length; i++) {
|
||||
bulk.raw(operations[i]);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
return callback(err);
|
||||
}
|
||||
// Execute the bulk
|
||||
bulk.execute({ ...options, session }).then(result => callback(undefined, result), error => callback(error));
|
||||
}
|
||||
}
|
||||
exports.BulkWriteOperation = BulkWriteOperation;
|
||||
(0, operation_1.defineAspects)(BulkWriteOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=bulk_write.js.map
|
||||
1
node_modules/mongodb/lib/operations/bulk_write.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/bulk_write.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"bulk_write.js","sourceRoot":"","sources":["../../src/operations/bulk_write.ts"],"names":[],"mappings":";;;AAUA,2CAAuE;AAEvE,gBAAgB;AAChB,MAAa,kBAAmB,SAAQ,6BAAkC;IAKxE,YACE,UAAsB,EACtB,UAAmC,EACnC,OAAyB;QAEzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAAmC;QAEnC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;QAE9F,4BAA4B;QAC5B,MAAM,IAAI,GACR,OAAO,CAAC,OAAO,KAAK,KAAK;YACvB,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC;YACzC,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAE5C,6CAA6C;QAC7C,IAAI;YACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC1C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;aACzB;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;SACtB;QAED,mBAAmB;QACnB,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CACxC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,EACrC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzB,CAAC;IACJ,CAAC;CACF;AA9CD,gDA8CC;AAED,IAAA,yBAAa,EAAC,kBAAkB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
32
node_modules/mongodb/lib/operations/collections.js
generated
vendored
Normal file
32
node_modules/mongodb/lib/operations/collections.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CollectionsOperation = void 0;
|
||||
const collection_1 = require("../collection");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class CollectionsOperation extends operation_1.AbstractOperation {
|
||||
constructor(db, options) {
|
||||
super(options);
|
||||
this.options = options;
|
||||
this.db = db;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
// Let's get the collection names
|
||||
this.db
|
||||
.listCollections({}, { ...this.options, nameOnly: true, readPreference: this.readPreference, session })
|
||||
.toArray()
|
||||
.then(documents => {
|
||||
const collections = [];
|
||||
for (const { name } of documents) {
|
||||
if (!name.includes('$')) {
|
||||
// Filter collections removing any illegal ones
|
||||
collections.push(new collection_1.Collection(this.db, name, this.db.s.options));
|
||||
}
|
||||
}
|
||||
// Return the collection objects
|
||||
callback(undefined, collections);
|
||||
}, error => callback(error));
|
||||
}
|
||||
}
|
||||
exports.CollectionsOperation = CollectionsOperation;
|
||||
//# sourceMappingURL=collections.js.map
|
||||
1
node_modules/mongodb/lib/operations/collections.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/collections.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/operations/collections.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAK3C,2CAAkE;AAMlE,gBAAgB;AAChB,MAAa,oBAAqB,SAAQ,6BAA+B;IAIvE,YAAY,EAAM,EAAE,OAA2B;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAAgC;QAEhC,iCAAiC;QACjC,IAAI,CAAC,EAAE;aACJ,eAAe,CACd,EAAE,EACF,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAClF;aACA,OAAO,EAAE;aACT,IAAI,CACH,SAAS,CAAC,EAAE;YACV,MAAM,WAAW,GAAG,EAAE,CAAC;YACvB,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS,EAAE;gBAChC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBACvB,+CAA+C;oBAC/C,WAAW,CAAC,IAAI,CAAC,IAAI,uBAAU,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;iBACpE;aACF;YACD,gCAAgC;YAChC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,EACD,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzB,CAAC;IACN,CAAC;CACF;AArCD,oDAqCC"}
|
||||
78
node_modules/mongodb/lib/operations/command.js
generated
vendored
Normal file
78
node_modules/mongodb/lib/operations/command.js
generated
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const explain_1 = require("../explain");
|
||||
const read_concern_1 = require("../read_concern");
|
||||
const server_selection_1 = require("../sdam/server_selection");
|
||||
const utils_1 = require("../utils");
|
||||
const write_concern_1 = require("../write_concern");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class CommandOperation extends operation_1.AbstractOperation {
|
||||
constructor(parent, options) {
|
||||
super(options);
|
||||
this.options = options ?? {};
|
||||
// NOTE: this was explicitly added for the add/remove user operations, it's likely
|
||||
// something we'd want to reconsider. Perhaps those commands can use `Admin`
|
||||
// as a parent?
|
||||
const dbNameOverride = options?.dbName || options?.authdb;
|
||||
if (dbNameOverride) {
|
||||
this.ns = new utils_1.MongoDBNamespace(dbNameOverride, '$cmd');
|
||||
}
|
||||
else {
|
||||
this.ns = parent
|
||||
? parent.s.namespace.withCollection('$cmd')
|
||||
: new utils_1.MongoDBNamespace('admin', '$cmd');
|
||||
}
|
||||
this.readConcern = read_concern_1.ReadConcern.fromOptions(options);
|
||||
this.writeConcern = write_concern_1.WriteConcern.fromOptions(options);
|
||||
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE)) {
|
||||
this.explain = explain_1.Explain.fromOptions(options);
|
||||
}
|
||||
else if (options?.explain != null) {
|
||||
throw new error_1.MongoInvalidArgumentError(`Option "explain" is not supported on this command`);
|
||||
}
|
||||
}
|
||||
get canRetryWrite() {
|
||||
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE)) {
|
||||
return this.explain == null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
executeCommand(server, session, cmd, callback) {
|
||||
// TODO: consider making this a non-enumerable property
|
||||
this.server = server;
|
||||
const options = {
|
||||
...this.options,
|
||||
...this.bsonOptions,
|
||||
readPreference: this.readPreference,
|
||||
session
|
||||
};
|
||||
const serverWireVersion = (0, utils_1.maxWireVersion)(server);
|
||||
const inTransaction = this.session && this.session.inTransaction();
|
||||
if (this.readConcern && (0, utils_1.commandSupportsReadConcern)(cmd) && !inTransaction) {
|
||||
Object.assign(cmd, { readConcern: this.readConcern });
|
||||
}
|
||||
if (this.trySecondaryWrite && serverWireVersion < server_selection_1.MIN_SECONDARY_WRITE_WIRE_VERSION) {
|
||||
options.omitReadPreference = true;
|
||||
}
|
||||
if (this.writeConcern && this.hasAspect(operation_1.Aspect.WRITE_OPERATION) && !inTransaction) {
|
||||
Object.assign(cmd, { writeConcern: this.writeConcern });
|
||||
}
|
||||
if (options.collation &&
|
||||
typeof options.collation === 'object' &&
|
||||
!this.hasAspect(operation_1.Aspect.SKIP_COLLATION)) {
|
||||
Object.assign(cmd, { collation: options.collation });
|
||||
}
|
||||
if (typeof options.maxTimeMS === 'number') {
|
||||
cmd.maxTimeMS = options.maxTimeMS;
|
||||
}
|
||||
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE) && this.explain) {
|
||||
cmd = (0, utils_1.decorateWithExplain)(cmd, this.explain);
|
||||
}
|
||||
server.command(this.ns, cmd, options, callback);
|
||||
}
|
||||
}
|
||||
exports.CommandOperation = CommandOperation;
|
||||
//# sourceMappingURL=command.js.map
|
||||
1
node_modules/mongodb/lib/operations/command.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/command.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/operations/command.ts"],"names":[],"mappings":";;;AACA,oCAAqD;AACrD,wCAAqD;AACrD,kDAA8C;AAG9C,+DAA4E;AAE5E,oCAMkB;AAClB,oDAAqE;AAErE,2CAA0E;AAoD1E,gBAAgB;AAChB,MAAsB,gBAAoB,SAAQ,6BAAoB;IAMpE,YAAY,MAAwB,EAAE,OAAiC;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;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,CAAC;SAC9C;QAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;CACF;AAxFD,4CAwFC"}
|
||||
69
node_modules/mongodb/lib/operations/common_functions.js
generated
vendored
Normal file
69
node_modules/mongodb/lib/operations/common_functions.js
generated
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.prepareDocs = exports.indexInformation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
function indexInformation(db, name, _optionsOrCallback, _callback) {
|
||||
let options = _optionsOrCallback;
|
||||
let callback = _callback;
|
||||
if ('function' === typeof _optionsOrCallback) {
|
||||
callback = _optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
// If we specified full information
|
||||
const full = options.full == null ? false : options.full;
|
||||
let topology;
|
||||
try {
|
||||
topology = (0, utils_1.getTopology)(db);
|
||||
}
|
||||
catch (error) {
|
||||
return callback(error);
|
||||
}
|
||||
// Did the user destroy the topology
|
||||
if (topology.isDestroyed())
|
||||
return callback(new error_1.MongoTopologyClosedError());
|
||||
// Process all the results from the index command and collection
|
||||
function processResults(indexes) {
|
||||
// Contains all the information
|
||||
const info = {};
|
||||
// Process all the indexes
|
||||
for (let i = 0; i < indexes.length; i++) {
|
||||
const index = indexes[i];
|
||||
// Let's unpack the object
|
||||
info[index.name] = [];
|
||||
for (const name in index.key) {
|
||||
info[index.name].push([name, index.key[name]]);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
// Get the list of indexes of the specified collection
|
||||
db.collection(name)
|
||||
.listIndexes(options)
|
||||
.toArray()
|
||||
.then(indexes => {
|
||||
if (!Array.isArray(indexes))
|
||||
return callback(undefined, []);
|
||||
if (full)
|
||||
return callback(undefined, indexes);
|
||||
callback(undefined, processResults(indexes));
|
||||
}, error => callback(error));
|
||||
}
|
||||
exports.indexInformation = indexInformation;
|
||||
function prepareDocs(coll, docs, options) {
|
||||
const forceServerObjectId = typeof options.forceServerObjectId === 'boolean'
|
||||
? options.forceServerObjectId
|
||||
: coll.s.db.options?.forceServerObjectId;
|
||||
// no need to modify the docs if server sets the ObjectId
|
||||
if (forceServerObjectId === true) {
|
||||
return docs;
|
||||
}
|
||||
return docs.map(doc => {
|
||||
if (doc._id == null) {
|
||||
doc._id = coll.s.pkFactory.createPk();
|
||||
}
|
||||
return doc;
|
||||
});
|
||||
}
|
||||
exports.prepareDocs = prepareDocs;
|
||||
//# sourceMappingURL=common_functions.js.map
|
||||
1
node_modules/mongodb/lib/operations/common_functions.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/common_functions.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"common_functions.js","sourceRoot":"","sources":["../../src/operations/common_functions.ts"],"names":[],"mappings":";;;AAGA,oCAAoD;AAGpD,oCAAiD;AAqBjD,SAAgB,gBAAgB,CAC9B,EAAM,EACN,IAAY,EACZ,kBAAsD,EACtD,SAAoB;IAEpB,IAAI,OAAO,GAAG,kBAA6C,CAAC;IAC5D,IAAI,QAAQ,GAAG,SAAqB,CAAC;IACrC,IAAI,UAAU,KAAK,OAAO,kBAAkB,EAAE;QAC5C,QAAQ,GAAG,kBAAkB,CAAC;QAC9B,OAAO,GAAG,EAAE,CAAC;KACd;IACD,mCAAmC;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAEzD,IAAI,QAAQ,CAAC;IACb,IAAI;QACF,QAAQ,GAAG,IAAA,mBAAW,EAAC,EAAE,CAAC,CAAC;KAC5B;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;KACxB;IAED,oCAAoC;IACpC,IAAI,QAAQ,CAAC,WA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CAAC,mBAAmB,KAAK,SAAS;QAC9C,CAAC,CAAC,OAAO,CAAC,mBAAmB;QAC7B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,CAAC;IAE7C,yDAAyD;IACzD,IAAI,mBAAmB,KAAK,IAAI,EAAE;QAChC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACpB,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE;YACnB,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;SACvC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,kCAsBC"}
|
||||
39
node_modules/mongodb/lib/operations/count.js
generated
vendored
Normal file
39
node_modules/mongodb/lib/operations/count.js
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CountOperation = void 0;
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class CountOperation extends command_1.CommandOperation {
|
||||
constructor(namespace, filter, options) {
|
||||
super({ s: { namespace: namespace } }, options);
|
||||
this.options = options;
|
||||
this.collectionName = namespace.collection;
|
||||
this.query = filter;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const options = this.options;
|
||||
const cmd = {
|
||||
count: this.collectionName,
|
||||
query: this.query
|
||||
};
|
||||
if (typeof options.limit === 'number') {
|
||||
cmd.limit = options.limit;
|
||||
}
|
||||
if (typeof options.skip === 'number') {
|
||||
cmd.skip = options.skip;
|
||||
}
|
||||
if (options.hint != null) {
|
||||
cmd.hint = options.hint;
|
||||
}
|
||||
if (typeof options.maxTimeMS === 'number') {
|
||||
cmd.maxTimeMS = options.maxTimeMS;
|
||||
}
|
||||
super.executeCommand(server, session, cmd, (err, result) => {
|
||||
callback(err, result ? result.n : 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CountOperation = CountOperation;
|
||||
(0, operation_1.defineAspects)(CountOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE]);
|
||||
//# sourceMappingURL=count.js.map
|
||||
1
node_modules/mongodb/lib/operations/count.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/count.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"count.js","sourceRoot":"","sources":["../../src/operations/count.ts"],"names":[],"mappings":";;;AAKA,uCAAsE;AACtE,2CAAoD;AAcpD,gBAAgB;AAChB,MAAa,cAAe,SAAQ,0BAAwB;IAK1D,YAAY,SAA2B,EAAE,MAAgB,EAAE,OAAqB;QAC9E,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAA2B,EAAE,OAAO,CAAC,CAAC;QAEzE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;IACtB,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA0B;QAE1B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,GAAG,GAAa;YACpB,KAAK,EAAE,IAAI,CAAC,cAAc;YAC1B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;QAEF,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE;YACrC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;SAC3B;QAED,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;YACpC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;SACzB;QAED,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE;YACxB,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;SACzB;QAED,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE;YACzC,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;SACnC;QAED,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACzD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5CD,wCA4CC;AAED,IAAA,yBAAa,EAAC,cAAc,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
||||
37
node_modules/mongodb/lib/operations/count_documents.js
generated
vendored
Normal file
37
node_modules/mongodb/lib/operations/count_documents.js
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CountDocumentsOperation = void 0;
|
||||
const aggregate_1 = require("./aggregate");
|
||||
/** @internal */
|
||||
class CountDocumentsOperation extends aggregate_1.AggregateOperation {
|
||||
constructor(collection, query, options) {
|
||||
const pipeline = [];
|
||||
pipeline.push({ $match: query });
|
||||
if (typeof options.skip === 'number') {
|
||||
pipeline.push({ $skip: options.skip });
|
||||
}
|
||||
if (typeof options.limit === 'number') {
|
||||
pipeline.push({ $limit: options.limit });
|
||||
}
|
||||
pipeline.push({ $group: { _id: 1, n: { $sum: 1 } } });
|
||||
super(collection.s.namespace, pipeline, options);
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, (err, result) => {
|
||||
if (err || !result) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
// NOTE: We're avoiding creating a cursor here to reduce the callstack.
|
||||
const response = result;
|
||||
if (response.cursor == null || response.cursor.firstBatch == null) {
|
||||
callback(undefined, 0);
|
||||
return;
|
||||
}
|
||||
const docs = response.cursor.firstBatch;
|
||||
callback(undefined, docs.length ? docs[0].n : 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CountDocumentsOperation = CountDocumentsOperation;
|
||||
//# sourceMappingURL=count_documents.js.map
|
||||
1
node_modules/mongodb/lib/operations/count_documents.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/count_documents.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"count_documents.js","sourceRoot":"","sources":["../../src/operations/count_documents.ts"],"names":[],"mappings":";;;AAKA,2CAAmE;AAUnE,gBAAgB;AAChB,MAAa,uBAAwB,SAAQ,8BAA0B;IACrE,YAAY,UAAsB,EAAE,KAAe,EAAE,OAA8B;QACjF,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAEjC,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;YACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;SACxC;QAED,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE;YACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;SAC1C;QAED,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAEtD,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA0B;QAE1B,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YAC7C,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE;gBAClB,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACd,OAAO;aACR;YAED,uEAAuE;YACvE,MAAM,QAAQ,GAAG,MAA6B,CAAC;YAC/C,IAAI,QAAQ,CAAC,MAAM,IAAI,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,UAAU,IAAI,IAAI,EAAE;gBACjE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;gBACvB,OAAO;aACR;YAED,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;YACxC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxCD,0DAwCC"}
|
||||
101
node_modules/mongodb/lib/operations/create_collection.js
generated
vendored
Normal file
101
node_modules/mongodb/lib/operations/create_collection.js
generated
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateCollectionOperation = void 0;
|
||||
const collection_1 = require("../collection");
|
||||
const command_1 = require("./command");
|
||||
const indexes_1 = require("./indexes");
|
||||
const operation_1 = require("./operation");
|
||||
const ILLEGAL_COMMAND_FIELDS = new Set([
|
||||
'w',
|
||||
'wtimeout',
|
||||
'j',
|
||||
'fsync',
|
||||
'autoIndexId',
|
||||
'pkFactory',
|
||||
'raw',
|
||||
'readPreference',
|
||||
'session',
|
||||
'readConcern',
|
||||
'writeConcern',
|
||||
'raw',
|
||||
'fieldsAsRaw',
|
||||
'useBigInt64',
|
||||
'promoteLongs',
|
||||
'promoteValues',
|
||||
'promoteBuffers',
|
||||
'bsonRegExp',
|
||||
'serializeFunctions',
|
||||
'ignoreUndefined',
|
||||
'enableUtf8Validation'
|
||||
]);
|
||||
/** @internal */
|
||||
class CreateCollectionOperation extends command_1.CommandOperation {
|
||||
constructor(db, name, options = {}) {
|
||||
super(db, options);
|
||||
this.options = options;
|
||||
this.db = db;
|
||||
this.name = name;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
(async () => {
|
||||
const db = this.db;
|
||||
const name = this.name;
|
||||
const options = this.options;
|
||||
const encryptedFields = options.encryptedFields ??
|
||||
db.s.client.options.autoEncryption?.encryptedFieldsMap?.[`${db.databaseName}.${name}`];
|
||||
if (encryptedFields) {
|
||||
// Create auxilliary collections for queryable encryption support.
|
||||
const escCollection = encryptedFields.escCollection ?? `enxcol_.${name}.esc`;
|
||||
const eccCollection = encryptedFields.eccCollection ?? `enxcol_.${name}.ecc`;
|
||||
const ecocCollection = encryptedFields.ecocCollection ?? `enxcol_.${name}.ecoc`;
|
||||
for (const collectionName of [escCollection, eccCollection, ecocCollection]) {
|
||||
const createOp = new CreateCollectionOperation(db, collectionName, {
|
||||
clusteredIndex: {
|
||||
key: { _id: 1 },
|
||||
unique: true
|
||||
}
|
||||
});
|
||||
await createOp.executeWithoutEncryptedFieldsCheck(server, session);
|
||||
}
|
||||
if (!options.encryptedFields) {
|
||||
this.options = { ...this.options, encryptedFields };
|
||||
}
|
||||
}
|
||||
const coll = await this.executeWithoutEncryptedFieldsCheck(server, session);
|
||||
if (encryptedFields) {
|
||||
// Create the required index for queryable encryption support.
|
||||
const createIndexOp = new indexes_1.CreateIndexOperation(db, name, { __safeContent__: 1 }, {});
|
||||
await new Promise((resolve, reject) => {
|
||||
createIndexOp.execute(server, session, err => (err ? reject(err) : resolve()));
|
||||
});
|
||||
}
|
||||
return coll;
|
||||
})().then(coll => callback(undefined, coll), err => callback(err));
|
||||
}
|
||||
executeWithoutEncryptedFieldsCheck(server, session) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const db = this.db;
|
||||
const name = this.name;
|
||||
const options = this.options;
|
||||
const done = err => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve(new collection_1.Collection(db, name, options));
|
||||
};
|
||||
const cmd = { create: name };
|
||||
for (const n in options) {
|
||||
if (options[n] != null &&
|
||||
typeof options[n] !== 'function' &&
|
||||
!ILLEGAL_COMMAND_FIELDS.has(n)) {
|
||||
cmd[n] = options[n];
|
||||
}
|
||||
}
|
||||
// otherwise just execute the command
|
||||
super.executeCommand(server, session, cmd, done);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CreateCollectionOperation = CreateCollectionOperation;
|
||||
(0, operation_1.defineAspects)(CreateCollectionOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=create_collection.js.map
|
||||
1
node_modules/mongodb/lib/operations/create_collection.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/create_collection.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"create_collection.js","sourceRoot":"","sources":["../../src/operations/create_collection.ts"],"names":[],"mappings":";;;AACA,8CAA2C;AAM3C,uCAAsE;AACtE,uCAAiD;AACjD,2CAAoD;AAEpD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,GAAG;IACH,UAAU;IACV,GAAG;IACH,OAAO;IACP,aAAa;IACb,WAAW;IACX,KAAK;IACL,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,cAAc;IACd,KAAK;IACL,aAAa;IACb,aAAa;IACb,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,YAAY;IACZ,oBAAoB;IACpB,iBAAiB;IACjB,sBAAsB;CACvB,CAAC,CAAC;AAmEH,gBAAgB;AAChB,MAAa,yBAA0B,SAAQ,0BAA4B;IAKzE,YAAY,EAAM,EAAE,IAAY,EAAE,UAAmC,EAAE;QACrE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;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AAO,CAAC,CAAC,CAAC;YAC7C,CAAC,CAAC;YAEF,MAAM,GAAG,GAAa,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;YACvC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;gBACvB,IACG,OAAe,CAAC,CAAC,CAAC,IAAI,IAAI;oBAC3B,OAAQ,OAAe,CAAC,CAAC,CAAC,KAAK,UAAU;oBACzC,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAC9B;oBACA,GAAG,CAAC,CAAC,CAAC,GAAI,OAAe,CAAC,CAAC,CAAC,CAAC;iBAC9B;aACF;YAED,qCAAqC;YACrC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjGD,8DAiGC;AAED,IAAA,yBAAa,EAAC,yBAAyB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
119
node_modules/mongodb/lib/operations/delete.js
generated
vendored
Normal file
119
node_modules/mongodb/lib/operations/delete.js
generated
vendored
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeDeleteStatement = exports.DeleteManyOperation = exports.DeleteOneOperation = exports.DeleteOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class DeleteOperation extends command_1.CommandOperation {
|
||||
constructor(ns, statements, options) {
|
||||
super(undefined, options);
|
||||
this.options = options;
|
||||
this.ns = ns;
|
||||
this.statements = statements;
|
||||
}
|
||||
get canRetryWrite() {
|
||||
if (super.canRetryWrite === false) {
|
||||
return false;
|
||||
}
|
||||
return this.statements.every(op => (op.limit != null ? op.limit > 0 : true));
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const options = this.options ?? {};
|
||||
const ordered = typeof options.ordered === 'boolean' ? options.ordered : true;
|
||||
const command = {
|
||||
delete: this.ns.collection,
|
||||
deletes: this.statements,
|
||||
ordered
|
||||
};
|
||||
if (options.let) {
|
||||
command.let = options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
|
||||
if (unacknowledgedWrite) {
|
||||
if (this.statements.find((o) => o.hint)) {
|
||||
// TODO(NODE-3541): fix error for hint with unacknowledged writes
|
||||
callback(new error_1.MongoCompatibilityError(`hint is not supported with unacknowledged writes`));
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.DeleteOperation = DeleteOperation;
|
||||
class DeleteOneOperation extends DeleteOperation {
|
||||
constructor(collection, filter, options) {
|
||||
super(collection.s.namespace, [makeDeleteStatement(filter, { ...options, limit: 1 })], options);
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, (err, res) => {
|
||||
if (err || res == null)
|
||||
return callback(err);
|
||||
if (res.code)
|
||||
return callback(new error_1.MongoServerError(res));
|
||||
if (res.writeErrors)
|
||||
return callback(new error_1.MongoServerError(res.writeErrors[0]));
|
||||
if (this.explain)
|
||||
return callback(undefined, res);
|
||||
callback(undefined, {
|
||||
acknowledged: this.writeConcern?.w !== 0 ?? true,
|
||||
deletedCount: res.n
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.DeleteOneOperation = DeleteOneOperation;
|
||||
class DeleteManyOperation extends DeleteOperation {
|
||||
constructor(collection, filter, options) {
|
||||
super(collection.s.namespace, [makeDeleteStatement(filter, options)], options);
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, (err, res) => {
|
||||
if (err || res == null)
|
||||
return callback(err);
|
||||
if (res.code)
|
||||
return callback(new error_1.MongoServerError(res));
|
||||
if (res.writeErrors)
|
||||
return callback(new error_1.MongoServerError(res.writeErrors[0]));
|
||||
if (this.explain)
|
||||
return callback(undefined, res);
|
||||
callback(undefined, {
|
||||
acknowledged: this.writeConcern?.w !== 0 ?? true,
|
||||
deletedCount: res.n
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.DeleteManyOperation = DeleteManyOperation;
|
||||
function makeDeleteStatement(filter, options) {
|
||||
const op = {
|
||||
q: filter,
|
||||
limit: typeof options.limit === 'number' ? options.limit : 0
|
||||
};
|
||||
if (options.collation) {
|
||||
op.collation = options.collation;
|
||||
}
|
||||
if (options.hint) {
|
||||
op.hint = options.hint;
|
||||
}
|
||||
return op;
|
||||
}
|
||||
exports.makeDeleteStatement = makeDeleteStatement;
|
||||
(0, operation_1.defineAspects)(DeleteOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(DeleteOneOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SKIP_COLLATION
|
||||
]);
|
||||
(0, operation_1.defineAspects)(DeleteManyOperation, [
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SKIP_COLLATION
|
||||
]);
|
||||
//# sourceMappingURL=delete.js.map
|
||||
1
node_modules/mongodb/lib/operations/delete.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/delete.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/operations/delete.ts"],"names":[],"mappings":";;;AAEA,oCAAqE;AAKrE,uCAAwF;AACxF,2CAA0D;AAkC1D,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,0BAA8B;IAIjE,YAAY,EAAoB,EAAE,UAA6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OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC7D,CAAC;IAEF,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,EAAE,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;KAClC;IAED,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,EAAE,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;KACxB;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAlBD,kDAkBC;AAED,IAAA,yBAAa,EAAC,eAAe,EAAE,CAAC,kBAAM,CAAC,SAAS,EAAE,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AAC3E,IAAA,yBAAa,EAAC,kBAAkB,EAAE;IAChC,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,cAAc;CACtB,CAAC,CAAC;AACH,IAAA,yBAAa,EAAC,mBAAmB,EAAE;IACjC,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,cAAc;CACtB,CAAC,CAAC"}
|
||||
67
node_modules/mongodb/lib/operations/distinct.js
generated
vendored
Normal file
67
node_modules/mongodb/lib/operations/distinct.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DistinctOperation = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/**
|
||||
* Return a list of distinct values for the given key across a collection.
|
||||
* @internal
|
||||
*/
|
||||
class DistinctOperation extends command_1.CommandOperation {
|
||||
/**
|
||||
* Construct a Distinct operation.
|
||||
*
|
||||
* @param collection - Collection instance.
|
||||
* @param key - Field of the document to find distinct values for.
|
||||
* @param query - The query for filtering the set of documents to which we apply the distinct filter.
|
||||
* @param options - Optional settings. See Collection.prototype.distinct for a list of options.
|
||||
*/
|
||||
constructor(collection, key, query, options) {
|
||||
super(collection, options);
|
||||
this.options = options ?? {};
|
||||
this.collection = collection;
|
||||
this.key = key;
|
||||
this.query = query;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const coll = this.collection;
|
||||
const key = this.key;
|
||||
const query = this.query;
|
||||
const options = this.options;
|
||||
// Distinct command
|
||||
const cmd = {
|
||||
distinct: coll.collectionName,
|
||||
key: key,
|
||||
query: query
|
||||
};
|
||||
// Add maxTimeMS if defined
|
||||
if (typeof options.maxTimeMS === 'number') {
|
||||
cmd.maxTimeMS = options.maxTimeMS;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (typeof options.comment !== 'undefined') {
|
||||
cmd.comment = options.comment;
|
||||
}
|
||||
// Do we have a readConcern specified
|
||||
(0, utils_1.decorateWithReadConcern)(cmd, coll, options);
|
||||
// Have we specified collation
|
||||
try {
|
||||
(0, utils_1.decorateWithCollation)(cmd, coll, options);
|
||||
}
|
||||
catch (err) {
|
||||
return callback(err);
|
||||
}
|
||||
super.executeCommand(server, session, cmd, (err, result) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
callback(undefined, this.explain ? result : result.values);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.DistinctOperation = DistinctOperation;
|
||||
(0, operation_1.defineAspects)(DistinctOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE, operation_1.Aspect.EXPLAINABLE]);
|
||||
//# sourceMappingURL=distinct.js.map
|
||||
1
node_modules/mongodb/lib/operations/distinct.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/distinct.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"distinct.js","sourceRoot":"","sources":["../../src/operations/distinct.ts"],"names":[],"mappings":";;;AAIA,oCAAoF;AAC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AC3C;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;SACtB;QAED,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACzD,IAAI,GAAG,EAAE;gBACP,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACd,OAAO;aACR;YAED,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxED,8CAwEC;AAED,IAAA,yBAAa,EAAC,iBAAiB,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,SAAS,EAAE,kBAAM,CAAC,WAAW,CAAC,CAAC,CAAC"}
|
||||
83
node_modules/mongodb/lib/operations/drop.js
generated
vendored
Normal file
83
node_modules/mongodb/lib/operations/drop.js
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DropDatabaseOperation = exports.DropCollectionOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class DropCollectionOperation extends command_1.CommandOperation {
|
||||
constructor(db, name, options = {}) {
|
||||
super(db, options);
|
||||
this.db = db;
|
||||
this.options = options;
|
||||
this.name = name;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
(async () => {
|
||||
const db = this.db;
|
||||
const options = this.options;
|
||||
const name = this.name;
|
||||
const encryptedFieldsMap = db.s.client.options.autoEncryption?.encryptedFieldsMap;
|
||||
let encryptedFields = options.encryptedFields ?? encryptedFieldsMap?.[`${db.databaseName}.${name}`];
|
||||
if (!encryptedFields && encryptedFieldsMap) {
|
||||
// If the MongoClient was configured with an encryptedFieldsMap,
|
||||
// and no encryptedFields config was available in it or explicitly
|
||||
// passed as an argument, the spec tells us to look one up using
|
||||
// listCollections().
|
||||
const listCollectionsResult = await db
|
||||
.listCollections({ name }, { nameOnly: false })
|
||||
.toArray();
|
||||
encryptedFields = listCollectionsResult?.[0]?.options?.encryptedFields;
|
||||
}
|
||||
if (encryptedFields) {
|
||||
const escCollection = encryptedFields.escCollection || `enxcol_.${name}.esc`;
|
||||
const eccCollection = encryptedFields.eccCollection || `enxcol_.${name}.ecc`;
|
||||
const ecocCollection = encryptedFields.ecocCollection || `enxcol_.${name}.ecoc`;
|
||||
for (const collectionName of [escCollection, eccCollection, ecocCollection]) {
|
||||
// Drop auxilliary collections, ignoring potential NamespaceNotFound errors.
|
||||
const dropOp = new DropCollectionOperation(db, collectionName);
|
||||
try {
|
||||
await dropOp.executeWithoutEncryptedFieldsCheck(server, session);
|
||||
}
|
||||
catch (err) {
|
||||
if (!(err instanceof error_1.MongoServerError) ||
|
||||
err.code !== error_1.MONGODB_ERROR_CODES.NamespaceNotFound) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.executeWithoutEncryptedFieldsCheck(server, session);
|
||||
})().then(result => callback(undefined, result), err => callback(err));
|
||||
}
|
||||
executeWithoutEncryptedFieldsCheck(server, session) {
|
||||
return new Promise((resolve, reject) => {
|
||||
super.executeCommand(server, session, { drop: this.name }, (err, result) => {
|
||||
if (err)
|
||||
return reject(err);
|
||||
resolve(!!result.ok);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.DropCollectionOperation = DropCollectionOperation;
|
||||
/** @internal */
|
||||
class DropDatabaseOperation extends command_1.CommandOperation {
|
||||
constructor(db, options) {
|
||||
super(db, options);
|
||||
this.options = options;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.executeCommand(server, session, { dropDatabase: 1 }, (err, result) => {
|
||||
if (err)
|
||||
return callback(err);
|
||||
if (result.ok)
|
||||
return callback(undefined, true);
|
||||
callback(undefined, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.DropDatabaseOperation = DropDatabaseOperation;
|
||||
(0, operation_1.defineAspects)(DropCollectionOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(DropDatabaseOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=drop.js.map
|
||||
1
node_modules/mongodb/lib/operations/drop.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/drop.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"drop.js","sourceRoot":"","sources":["../../src/operations/drop.ts"],"names":[],"mappings":";;;AAEA,oCAAiE;AAIjE,uCAAsE;AACtE,2CAAoD;AAQpD,gBAAgB;AAChB,MAAa,uBAAwB,SAAQ,0BAAyB;IAKpE,YAAY,EAAM,EAAE,IAAY,EAAE,UAAiC,EAAE;QACnE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA2B;QAE3B,CAAC,KAAK,IAAI,EAAE;YACV,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;YAEvB,MAAM,kBAAkB,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,kBAAkB,CAAC;YAClF,IAAI,eAAe,GACjB,OAAO,CAAC,eAAe,IAAI,kBAAkB,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC,CAAC;YAEhF,IAAI,CAAC,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M,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
38
node_modules/mongodb/lib/operations/estimated_document_count.js
generated
vendored
Normal file
38
node_modules/mongodb/lib/operations/estimated_document_count.js
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EstimatedDocumentCountOperation = void 0;
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class EstimatedDocumentCountOperation extends command_1.CommandOperation {
|
||||
constructor(collection, options = {}) {
|
||||
super(collection, options);
|
||||
this.options = options;
|
||||
this.collectionName = collection.collectionName;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const cmd = { count: this.collectionName };
|
||||
if (typeof this.options.maxTimeMS === 'number') {
|
||||
cmd.maxTimeMS = this.options.maxTimeMS;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (this.options.comment !== undefined) {
|
||||
cmd.comment = this.options.comment;
|
||||
}
|
||||
super.executeCommand(server, session, cmd, (err, response) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
callback(undefined, response?.n || 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.EstimatedDocumentCountOperation = EstimatedDocumentCountOperation;
|
||||
(0, operation_1.defineAspects)(EstimatedDocumentCountOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING
|
||||
]);
|
||||
//# sourceMappingURL=estimated_document_count.js.map
|
||||
1
node_modules/mongodb/lib/operations/estimated_document_count.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/estimated_document_count.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"estimated_document_count.js","sourceRoot":"","sources":["../../src/operations/estimated_document_count.ts"],"names":[],"mappings":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endored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EvalOperation = void 0;
|
||||
const bson_1 = require("../bson");
|
||||
const error_1 = require("../error");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
const command_1 = require("./command");
|
||||
/** @internal */
|
||||
class EvalOperation extends command_1.CommandOperation {
|
||||
constructor(db, code, parameters, options) {
|
||||
super(db, options);
|
||||
this.options = options ?? {};
|
||||
this.code = code;
|
||||
this.parameters = parameters;
|
||||
// force primary read preference
|
||||
Object.defineProperty(this, 'readPreference', {
|
||||
value: read_preference_1.ReadPreference.primary,
|
||||
configurable: false,
|
||||
writable: false
|
||||
});
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
let finalCode = this.code;
|
||||
let finalParameters = [];
|
||||
// If not a code object translate to one
|
||||
if (!(finalCode && finalCode._bsontype === 'Code')) {
|
||||
finalCode = new bson_1.Code(finalCode);
|
||||
}
|
||||
// Ensure the parameters are correct
|
||||
if (this.parameters != null && typeof this.parameters !== 'function') {
|
||||
finalParameters = Array.isArray(this.parameters) ? this.parameters : [this.parameters];
|
||||
}
|
||||
// Create execution selector
|
||||
const cmd = { $eval: finalCode, args: finalParameters };
|
||||
// Check if the nolock parameter is passed in
|
||||
if (this.options.nolock) {
|
||||
cmd.nolock = this.options.nolock;
|
||||
}
|
||||
// Execute the command
|
||||
super.executeCommand(server, session, cmd, (err, result) => {
|
||||
if (err)
|
||||
return callback(err);
|
||||
if (result && result.ok === 1) {
|
||||
return callback(undefined, result.retval);
|
||||
}
|
||||
if (result) {
|
||||
callback(new error_1.MongoServerError({ message: `eval failed: ${result.errmsg}` }));
|
||||
return;
|
||||
}
|
||||
callback(err, result);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.EvalOperation = EvalOperation;
|
||||
//# sourceMappingURL=eval.js.map
|
||||
1
node_modules/mongodb/lib/operations/eval.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/eval.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"eval.js","sourceRoot":"","sources":["../../src/operations/eval.ts"],"names":[],"mappings":";;;AAAA,kCAAyC;AAGzC,oCAA4C;AAC5C,wDAAoD;AAIpD,uCAAsE;AAOtE,gBAAgB;AAChB,MAAa,aAAc,SAAQ,0BAA0B;IAK3D,YACE,EAAmB,EACnB,IAAU,EACV,UAAkC,EAClC,OAAqB;QAErB,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEnB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,gCAAgC;QAChC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE;YAC5C,KAAK,EAAE,gCAAc,CAAC,OAAO;YAC7B,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA4B;QAE5B,IAAI,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,IAAI,eAAe,GAAe,EAAE,CAAC;QAErC,wCAAwC;QACxC,IAAI,CAAC,CAAC,SAAS,IAAK,SAA8C,CAAC,SAAS,KAAK,MAAM,CAAC,EAAE;YACxF,SAAS,GAAG,IAAI,WAAI,CAAC,SAAkB,CAAC,CAAC;SAC1C;QAED,oCAAoC;QACpC,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,UAAU,EAAE;YACpE,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACxF;QAED,4BAA4B;QAC5B,MAAM,GAAG,GAAa,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;QAElE,6CAA6C;QAC7C,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACvB,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;SAClC;QAED,sBAAsB;QACtB,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACzD,IAAI,GAAG;gBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC9B,IAAI,MAAM,IAAI,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE;gBAC7B,OAAO,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;aAC3C;YAED,IAAI,MAAM,EAAE;gBACV,QAAQ,CAAC,IAAI,wBAAgB,CAAC,EAAE,OAAO,EAAE,gBAAgB,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;gBAC7E,OAAO;aACR;YAED,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjED,sCAiEC"}
|
||||
181
node_modules/mongodb/lib/operations/execute_operation.js
generated
vendored
Normal file
181
node_modules/mongodb/lib/operations/execute_operation.js
generated
vendored
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.executeOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
const server_selection_1 = require("../sdam/server_selection");
|
||||
const utils_1 = require("../utils");
|
||||
const operation_1 = require("./operation");
|
||||
const MMAPv1_RETRY_WRITES_ERROR_CODE = error_1.MONGODB_ERROR_CODES.IllegalOperation;
|
||||
const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.';
|
||||
function executeOperation(client, operation, callback) {
|
||||
return (0, utils_1.maybeCallback)(() => executeOperationAsync(client, operation), callback);
|
||||
}
|
||||
exports.executeOperation = executeOperation;
|
||||
async function executeOperationAsync(client, operation) {
|
||||
if (!(operation instanceof operation_1.AbstractOperation)) {
|
||||
// TODO(NODE-3483): Extend MongoRuntimeError
|
||||
throw new error_1.MongoRuntimeError('This method requires a valid operation instance');
|
||||
}
|
||||
if (client.topology == null) {
|
||||
// Auto connect on operation
|
||||
if (client.s.hasBeenClosed) {
|
||||
throw new error_1.MongoNotConnectedError('Client must be connected before running operations');
|
||||
}
|
||||
client.s.options[Symbol.for('@@mdb.skipPingOnConnect')] = true;
|
||||
try {
|
||||
await client.connect();
|
||||
}
|
||||
finally {
|
||||
delete client.s.options[Symbol.for('@@mdb.skipPingOnConnect')];
|
||||
}
|
||||
}
|
||||
const { topology } = client;
|
||||
if (topology == null) {
|
||||
throw new error_1.MongoRuntimeError('client.connect did not create a topology but also did not throw');
|
||||
}
|
||||
if (topology.shouldCheckForSessionSupport()) {
|
||||
await topology.selectServerAsync(read_preference_1.ReadPreference.primaryPreferred, {});
|
||||
}
|
||||
// The driver sessions spec mandates that we implicitly create sessions for operations
|
||||
// that are not explicitly provided with a session.
|
||||
let session = operation.session;
|
||||
let owner;
|
||||
if (topology.hasSessionSupport()) {
|
||||
if (session == null) {
|
||||
owner = Symbol();
|
||||
session = client.startSession({ owner, explicit: false });
|
||||
}
|
||||
else if (session.hasEnded) {
|
||||
throw new error_1.MongoExpiredSessionError('Use of expired sessions is not permitted');
|
||||
}
|
||||
else if (session.snapshotEnabled && !topology.capabilities.supportsSnapshotReads) {
|
||||
throw new error_1.MongoCompatibilityError('Snapshot reads require MongoDB 5.0 or later');
|
||||
}
|
||||
}
|
||||
else {
|
||||
// no session support
|
||||
if (session && session.explicit) {
|
||||
// If the user passed an explicit session and we are still, after server selection,
|
||||
// trying to run against a topology that doesn't support sessions we error out.
|
||||
throw new error_1.MongoCompatibilityError('Current topology does not support sessions');
|
||||
}
|
||||
else if (session && !session.explicit) {
|
||||
// We do not have to worry about ending the session because the server session has not been acquired yet
|
||||
delete operation.options.session;
|
||||
operation.clearSession();
|
||||
session = undefined;
|
||||
}
|
||||
}
|
||||
const readPreference = operation.readPreference ?? read_preference_1.ReadPreference.primary;
|
||||
const inTransaction = !!session?.inTransaction();
|
||||
if (inTransaction && !readPreference.equals(read_preference_1.ReadPreference.primary)) {
|
||||
throw new error_1.MongoTransactionError(`Read preference in a transaction must be primary, not: ${readPreference.mode}`);
|
||||
}
|
||||
if (session?.isPinned && session.transaction.isCommitted && !operation.bypassPinningCheck) {
|
||||
session.unpin();
|
||||
}
|
||||
let selector;
|
||||
if (operation.hasAspect(operation_1.Aspect.MUST_SELECT_SAME_SERVER)) {
|
||||
// GetMore and KillCursor operations must always select the same server, but run through
|
||||
// server selection to potentially force monitor checks if the server is
|
||||
// in an unknown state.
|
||||
selector = (0, server_selection_1.sameServerSelector)(operation.server?.description);
|
||||
}
|
||||
else if (operation.trySecondaryWrite) {
|
||||
// If operation should try to write to secondary use the custom server selector
|
||||
// otherwise provide the read preference.
|
||||
selector = (0, server_selection_1.secondaryWritableServerSelector)(topology.commonWireVersion, readPreference);
|
||||
}
|
||||
else {
|
||||
selector = readPreference;
|
||||
}
|
||||
const server = await topology.selectServerAsync(selector, { session });
|
||||
if (session == null) {
|
||||
// No session also means it is not retryable, early exit
|
||||
return operation.executeAsync(server, undefined);
|
||||
}
|
||||
if (!operation.hasAspect(operation_1.Aspect.RETRYABLE)) {
|
||||
// non-retryable operation, early exit
|
||||
try {
|
||||
return await operation.executeAsync(server, session);
|
||||
}
|
||||
finally {
|
||||
if (session?.owner != null && session.owner === owner) {
|
||||
await session.endSession().catch(() => null);
|
||||
}
|
||||
}
|
||||
}
|
||||
const willRetryRead = topology.s.options.retryReads && !inTransaction && operation.canRetryRead;
|
||||
const willRetryWrite = topology.s.options.retryWrites &&
|
||||
!inTransaction &&
|
||||
(0, utils_1.supportsRetryableWrites)(server) &&
|
||||
operation.canRetryWrite;
|
||||
const hasReadAspect = operation.hasAspect(operation_1.Aspect.READ_OPERATION);
|
||||
const hasWriteAspect = operation.hasAspect(operation_1.Aspect.WRITE_OPERATION);
|
||||
const willRetry = (hasReadAspect && willRetryRead) || (hasWriteAspect && willRetryWrite);
|
||||
if (hasWriteAspect && willRetryWrite) {
|
||||
operation.options.willRetryWrite = true;
|
||||
session.incrementTransactionNumber();
|
||||
}
|
||||
try {
|
||||
return await operation.executeAsync(server, session);
|
||||
}
|
||||
catch (operationError) {
|
||||
if (willRetry && operationError instanceof error_1.MongoError) {
|
||||
return await retryOperation(operation, operationError, {
|
||||
session,
|
||||
topology,
|
||||
selector
|
||||
});
|
||||
}
|
||||
throw operationError;
|
||||
}
|
||||
finally {
|
||||
if (session?.owner != null && session.owner === owner) {
|
||||
await session.endSession().catch(() => null);
|
||||
}
|
||||
}
|
||||
}
|
||||
async function retryOperation(operation, originalError, { session, topology, selector }) {
|
||||
const isWriteOperation = operation.hasAspect(operation_1.Aspect.WRITE_OPERATION);
|
||||
const isReadOperation = operation.hasAspect(operation_1.Aspect.READ_OPERATION);
|
||||
if (isWriteOperation && originalError.code === MMAPv1_RETRY_WRITES_ERROR_CODE) {
|
||||
throw new error_1.MongoServerError({
|
||||
message: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
|
||||
errmsg: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
|
||||
originalError
|
||||
});
|
||||
}
|
||||
if (isWriteOperation && !(0, error_1.isRetryableWriteError)(originalError)) {
|
||||
throw originalError;
|
||||
}
|
||||
if (isReadOperation && !(0, error_1.isRetryableReadError)(originalError)) {
|
||||
throw originalError;
|
||||
}
|
||||
if (originalError instanceof error_1.MongoNetworkError &&
|
||||
session.isPinned &&
|
||||
!session.inTransaction() &&
|
||||
operation.hasAspect(operation_1.Aspect.CURSOR_CREATING)) {
|
||||
// If we have a cursor and the initial command fails with a network error,
|
||||
// we can retry it on another connection. So we need to check it back in, clear the
|
||||
// pool for the service id, and retry again.
|
||||
session.unpin({ force: true, forceClear: true });
|
||||
}
|
||||
// select a new server, and attempt to retry the operation
|
||||
const server = await topology.selectServerAsync(selector, { session });
|
||||
if (isWriteOperation && !(0, utils_1.supportsRetryableWrites)(server)) {
|
||||
throw new error_1.MongoUnexpectedServerResponseError('Selected server does not support retryable writes');
|
||||
}
|
||||
try {
|
||||
return await operation.executeAsync(server, session);
|
||||
}
|
||||
catch (retryError) {
|
||||
if (retryError instanceof error_1.MongoError &&
|
||||
retryError.hasErrorLabel(error_1.MongoErrorLabel.NoWritesPerformed)) {
|
||||
throw originalError;
|
||||
}
|
||||
throw retryError;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=execute_operation.js.map
|
||||
1
node_modules/mongodb/lib/operations/execute_operation.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/execute_operation.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
156
node_modules/mongodb/lib/operations/find.js
generated
vendored
Normal file
156
node_modules/mongodb/lib/operations/find.js
generated
vendored
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FindOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const read_concern_1 = require("../read_concern");
|
||||
const sort_1 = require("../sort");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class FindOperation extends command_1.CommandOperation {
|
||||
constructor(collection, ns, filter = {}, options = {}) {
|
||||
super(collection, options);
|
||||
this.options = { ...options };
|
||||
delete this.options.writeConcern;
|
||||
this.ns = ns;
|
||||
if (typeof filter !== 'object' || Array.isArray(filter)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Query filter must be a plain object or ObjectId');
|
||||
}
|
||||
// If the filter is a buffer, validate that is a valid BSON document
|
||||
if (Buffer.isBuffer(filter)) {
|
||||
const objectSize = filter[0] | (filter[1] << 8) | (filter[2] << 16) | (filter[3] << 24);
|
||||
if (objectSize !== filter.length) {
|
||||
throw new error_1.MongoInvalidArgumentError(`Query filter raw message size does not match message header size [${filter.length}] != [${objectSize}]`);
|
||||
}
|
||||
}
|
||||
// special case passing in an ObjectId as a filter
|
||||
this.filter = filter != null && filter._bsontype === 'ObjectID' ? { _id: filter } : filter;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
this.server = server;
|
||||
const options = this.options;
|
||||
let findCommand = makeFindCommand(this.ns, this.filter, options);
|
||||
if (this.explain) {
|
||||
findCommand = (0, utils_1.decorateWithExplain)(findCommand, this.explain);
|
||||
}
|
||||
server.command(this.ns, findCommand, {
|
||||
...this.options,
|
||||
...this.bsonOptions,
|
||||
documentsReturnedIn: 'firstBatch',
|
||||
session
|
||||
}, callback);
|
||||
}
|
||||
}
|
||||
exports.FindOperation = FindOperation;
|
||||
function makeFindCommand(ns, filter, options) {
|
||||
const findCommand = {
|
||||
find: ns.collection,
|
||||
filter
|
||||
};
|
||||
if (options.sort) {
|
||||
findCommand.sort = (0, sort_1.formatSort)(options.sort);
|
||||
}
|
||||
if (options.projection) {
|
||||
let projection = options.projection;
|
||||
if (projection && Array.isArray(projection)) {
|
||||
projection = projection.length
|
||||
? projection.reduce((result, field) => {
|
||||
result[field] = 1;
|
||||
return result;
|
||||
}, {})
|
||||
: { _id: 1 };
|
||||
}
|
||||
findCommand.projection = projection;
|
||||
}
|
||||
if (options.hint) {
|
||||
findCommand.hint = (0, utils_1.normalizeHintField)(options.hint);
|
||||
}
|
||||
if (typeof options.skip === 'number') {
|
||||
findCommand.skip = options.skip;
|
||||
}
|
||||
if (typeof options.limit === 'number') {
|
||||
if (options.limit < 0) {
|
||||
findCommand.limit = -options.limit;
|
||||
findCommand.singleBatch = true;
|
||||
}
|
||||
else {
|
||||
findCommand.limit = options.limit;
|
||||
}
|
||||
}
|
||||
if (typeof options.batchSize === 'number') {
|
||||
if (options.batchSize < 0) {
|
||||
if (options.limit &&
|
||||
options.limit !== 0 &&
|
||||
Math.abs(options.batchSize) < Math.abs(options.limit)) {
|
||||
findCommand.limit = -options.batchSize;
|
||||
}
|
||||
findCommand.singleBatch = true;
|
||||
}
|
||||
else {
|
||||
findCommand.batchSize = options.batchSize;
|
||||
}
|
||||
}
|
||||
if (typeof options.singleBatch === 'boolean') {
|
||||
findCommand.singleBatch = options.singleBatch;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
findCommand.comment = options.comment;
|
||||
}
|
||||
if (typeof options.maxTimeMS === 'number') {
|
||||
findCommand.maxTimeMS = options.maxTimeMS;
|
||||
}
|
||||
const readConcern = read_concern_1.ReadConcern.fromOptions(options);
|
||||
if (readConcern) {
|
||||
findCommand.readConcern = readConcern.toJSON();
|
||||
}
|
||||
if (options.max) {
|
||||
findCommand.max = options.max;
|
||||
}
|
||||
if (options.min) {
|
||||
findCommand.min = options.min;
|
||||
}
|
||||
if (typeof options.returnKey === 'boolean') {
|
||||
findCommand.returnKey = options.returnKey;
|
||||
}
|
||||
if (typeof options.showRecordId === 'boolean') {
|
||||
findCommand.showRecordId = options.showRecordId;
|
||||
}
|
||||
if (typeof options.tailable === 'boolean') {
|
||||
findCommand.tailable = options.tailable;
|
||||
}
|
||||
if (typeof options.oplogReplay === 'boolean') {
|
||||
findCommand.oplogReplay = options.oplogReplay;
|
||||
}
|
||||
if (typeof options.timeout === 'boolean') {
|
||||
findCommand.noCursorTimeout = !options.timeout;
|
||||
}
|
||||
else if (typeof options.noCursorTimeout === 'boolean') {
|
||||
findCommand.noCursorTimeout = options.noCursorTimeout;
|
||||
}
|
||||
if (typeof options.awaitData === 'boolean') {
|
||||
findCommand.awaitData = options.awaitData;
|
||||
}
|
||||
if (typeof options.allowPartialResults === 'boolean') {
|
||||
findCommand.allowPartialResults = options.allowPartialResults;
|
||||
}
|
||||
if (options.collation) {
|
||||
findCommand.collation = options.collation;
|
||||
}
|
||||
if (typeof options.allowDiskUse === 'boolean') {
|
||||
findCommand.allowDiskUse = options.allowDiskUse;
|
||||
}
|
||||
if (options.let) {
|
||||
findCommand.let = options.let;
|
||||
}
|
||||
return findCommand;
|
||||
}
|
||||
(0, operation_1.defineAspects)(FindOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING
|
||||
]);
|
||||
//# sourceMappingURL=find.js.map
|
||||
1
node_modules/mongodb/lib/operations/find.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/find.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/operations/find.ts"],"names":[],"mappings":";;;AAEA,oCAAqD;AACrD,kDAA8C;AAG9C,kCAA2C;AAC3C,oCAA+F;AAC/F,uCAAwF;AACxF,2CAA0D;AA0D1D,gBAAgB;AAChB,MAAa,aAAc,SAAQ,0BAA0B;IAW3D,YACE,UAAkC,EAClC,EAAoB,EACpB,SAAmB,EAAE,EACrB,UAAuB,EAAE;QAEzB,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAE3B,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QAEb,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvD,MAAM,IAAI,iCAAyB,CAAC,iDAAiD,CAAC,CAAC;SACxF;QAED,oEAAoE;QACpE,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YAC3B,MAAM,UAAU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kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,eAAe;CACvB,CAAC,CAAC"}
|
||||
151
node_modules/mongodb/lib/operations/find_and_modify.js
generated
vendored
Normal file
151
node_modules/mongodb/lib/operations/find_and_modify.js
generated
vendored
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FindOneAndUpdateOperation = exports.FindOneAndReplaceOperation = exports.FindOneAndDeleteOperation = exports.ReturnDocument = void 0;
|
||||
const error_1 = require("../error");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
const sort_1 = require("../sort");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @public */
|
||||
exports.ReturnDocument = Object.freeze({
|
||||
BEFORE: 'before',
|
||||
AFTER: 'after'
|
||||
});
|
||||
function configureFindAndModifyCmdBaseUpdateOpts(cmdBase, options) {
|
||||
cmdBase.new = options.returnDocument === exports.ReturnDocument.AFTER;
|
||||
cmdBase.upsert = options.upsert === true;
|
||||
if (options.bypassDocumentValidation === true) {
|
||||
cmdBase.bypassDocumentValidation = options.bypassDocumentValidation;
|
||||
}
|
||||
return cmdBase;
|
||||
}
|
||||
/** @internal */
|
||||
class FindAndModifyOperation extends command_1.CommandOperation {
|
||||
constructor(collection, query, options) {
|
||||
super(collection, options);
|
||||
this.options = options ?? {};
|
||||
this.cmdBase = {
|
||||
remove: false,
|
||||
new: false,
|
||||
upsert: false
|
||||
};
|
||||
const sort = (0, sort_1.formatSort)(options.sort);
|
||||
if (sort) {
|
||||
this.cmdBase.sort = sort;
|
||||
}
|
||||
if (options.projection) {
|
||||
this.cmdBase.fields = options.projection;
|
||||
}
|
||||
if (options.maxTimeMS) {
|
||||
this.cmdBase.maxTimeMS = options.maxTimeMS;
|
||||
}
|
||||
// Decorate the findAndModify command with the write Concern
|
||||
if (options.writeConcern) {
|
||||
this.cmdBase.writeConcern = options.writeConcern;
|
||||
}
|
||||
if (options.let) {
|
||||
this.cmdBase.let = options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
this.cmdBase.comment = options.comment;
|
||||
}
|
||||
// force primary read preference
|
||||
this.readPreference = read_preference_1.ReadPreference.primary;
|
||||
this.collection = collection;
|
||||
this.query = query;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const coll = this.collection;
|
||||
const query = this.query;
|
||||
const options = { ...this.options, ...this.bsonOptions };
|
||||
// Create findAndModify command object
|
||||
const cmd = {
|
||||
findAndModify: coll.collectionName,
|
||||
query: query,
|
||||
...this.cmdBase
|
||||
};
|
||||
// Have we specified collation
|
||||
try {
|
||||
(0, utils_1.decorateWithCollation)(cmd, coll, options);
|
||||
}
|
||||
catch (err) {
|
||||
return callback(err);
|
||||
}
|
||||
if (options.hint) {
|
||||
// TODO: once this method becomes a CommandOperation we will have the server
|
||||
// in place to check.
|
||||
const unacknowledgedWrite = this.writeConcern?.w === 0;
|
||||
if (unacknowledgedWrite || (0, utils_1.maxWireVersion)(server) < 8) {
|
||||
callback(new error_1.MongoCompatibilityError('The current topology does not support a hint on findAndModify commands'));
|
||||
return;
|
||||
}
|
||||
cmd.hint = options.hint;
|
||||
}
|
||||
// Execute the command
|
||||
super.executeCommand(server, session, cmd, (err, result) => {
|
||||
if (err)
|
||||
return callback(err);
|
||||
return callback(undefined, result);
|
||||
});
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
class FindOneAndDeleteOperation extends FindAndModifyOperation {
|
||||
constructor(collection, filter, options) {
|
||||
// Basic validation
|
||||
if (filter == null || typeof filter !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
|
||||
}
|
||||
super(collection, filter, options);
|
||||
this.cmdBase.remove = true;
|
||||
}
|
||||
}
|
||||
exports.FindOneAndDeleteOperation = FindOneAndDeleteOperation;
|
||||
/** @internal */
|
||||
class FindOneAndReplaceOperation extends FindAndModifyOperation {
|
||||
constructor(collection, filter, replacement, options) {
|
||||
if (filter == null || typeof filter !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
|
||||
}
|
||||
if (replacement == null || typeof replacement !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "replacement" must be an object');
|
||||
}
|
||||
if ((0, utils_1.hasAtomicOperators)(replacement)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Replacement document must not contain atomic operators');
|
||||
}
|
||||
super(collection, filter, options);
|
||||
this.cmdBase.update = replacement;
|
||||
configureFindAndModifyCmdBaseUpdateOpts(this.cmdBase, options);
|
||||
}
|
||||
}
|
||||
exports.FindOneAndReplaceOperation = FindOneAndReplaceOperation;
|
||||
/** @internal */
|
||||
class FindOneAndUpdateOperation extends FindAndModifyOperation {
|
||||
constructor(collection, filter, update, options) {
|
||||
if (filter == null || typeof filter !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
|
||||
}
|
||||
if (update == null || typeof update !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "update" must be an object');
|
||||
}
|
||||
if (!(0, utils_1.hasAtomicOperators)(update)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Update document requires atomic operators');
|
||||
}
|
||||
super(collection, filter, options);
|
||||
this.cmdBase.update = update;
|
||||
configureFindAndModifyCmdBaseUpdateOpts(this.cmdBase, options);
|
||||
if (options.arrayFilters) {
|
||||
this.cmdBase.arrayFilters = options.arrayFilters;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.FindOneAndUpdateOperation = FindOneAndUpdateOperation;
|
||||
(0, operation_1.defineAspects)(FindAndModifyOperation, [
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.EXPLAINABLE
|
||||
]);
|
||||
//# sourceMappingURL=find_and_modify.js.map
|
||||
1
node_modules/mongodb/lib/operations/find_and_modify.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/find_and_modify.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"find_and_modify.js","sourceRoot":"","sources":["../../src/operations/find_and_modify.ts"],"names":[],"mappings":";;;AAEA,oCAA8E;AAC9E,wDAAoD;AAGpD,kCAAuD;AACvD,oCAA+F;AAE/F,uCAAsE;AACtE,2CAAoD;AAEpD,cAAc;AACD,QAAA,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACN,CAAC,CAAC;AA+EZ,SAAS,uCAAuC,CAC9C,OAA6B,EAC7B,OAA2D;IAE3D,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,cAAc,KAAK,sBAAc,CAAC,KAAK,CAAC;IAC9D,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC;IAEzC,IAAI,OAAO,CAAC,wBAAwB,KAAK,IAAI,EAAE;QAC7C,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;KACrE;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,gBAAgB;AAChB,MAAM,sBAAuB,SAAQ,0BAA0B;IAO7D,YACE,UAAsB,EACtB,KAAe,EACf,OAAqF;QAErF,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG;YACb,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,KAAK;YACV,MAAM,EAAE,KAAK;SACd,CAAC;QAEF,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;SAC1B;QAED,IAAI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;YACxB,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;SAClD;IACH,CAAC;CACF;AA3BD,8DA2BC;AAED,IAAA,yBAAa,EAAC,sBAAsB,EAAE;IACpC,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,WAAW;CACnB,CAAC,CAAC"}
|
||||
58
node_modules/mongodb/lib/operations/get_more.js
generated
vendored
Normal file
58
node_modules/mongodb/lib/operations/get_more.js
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GetMoreOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class GetMoreOperation extends operation_1.AbstractOperation {
|
||||
constructor(ns, cursorId, server, options) {
|
||||
super(options);
|
||||
this.options = options;
|
||||
this.ns = ns;
|
||||
this.cursorId = cursorId;
|
||||
this.server = server;
|
||||
}
|
||||
/**
|
||||
* Although there is a server already associated with the get more operation, the signature
|
||||
* for execute passes a server so we will just use that one.
|
||||
*/
|
||||
execute(server, session, callback) {
|
||||
if (server !== this.server) {
|
||||
return callback(new error_1.MongoRuntimeError('Getmore must run on the same server operation began on'));
|
||||
}
|
||||
if (this.cursorId == null || this.cursorId.isZero()) {
|
||||
return callback(new error_1.MongoRuntimeError('Unable to iterate cursor with no id'));
|
||||
}
|
||||
const collection = this.ns.collection;
|
||||
if (collection == null) {
|
||||
// Cursors should have adopted the namespace returned by MongoDB
|
||||
// which should always defined a collection name (even a pseudo one, ex. db.aggregate())
|
||||
return callback(new error_1.MongoRuntimeError('A collection name must be determined before getMore'));
|
||||
}
|
||||
const getMoreCmd = {
|
||||
getMore: this.cursorId,
|
||||
collection
|
||||
};
|
||||
if (typeof this.options.batchSize === 'number') {
|
||||
getMoreCmd.batchSize = Math.abs(this.options.batchSize);
|
||||
}
|
||||
if (typeof this.options.maxAwaitTimeMS === 'number') {
|
||||
getMoreCmd.maxTimeMS = this.options.maxAwaitTimeMS;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (this.options.comment !== undefined && (0, utils_1.maxWireVersion)(server) >= 9) {
|
||||
getMoreCmd.comment = this.options.comment;
|
||||
}
|
||||
const commandOptions = {
|
||||
returnFieldSelector: null,
|
||||
documentsReturnedIn: 'nextBatch',
|
||||
...this.options
|
||||
};
|
||||
server.command(this.ns, getMoreCmd, commandOptions, callback);
|
||||
}
|
||||
}
|
||||
exports.GetMoreOperation = GetMoreOperation;
|
||||
(0, operation_1.defineAspects)(GetMoreOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
|
||||
//# sourceMappingURL=get_more.js.map
|
||||
1
node_modules/mongodb/lib/operations/get_more.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/get_more.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"get_more.js","sourceRoot":"","sources":["../../src/operations/get_more.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAG7C,oCAAsE;AACtE,2CAAyF;AA+BzF,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,6BAAiB;IAIrD,YAAY,EAAoB,EAAE,QAAc,EAAE,MAAc,EAAE,OAAuB;QACvF,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACM,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA4B;QAE5B,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;YAC1B,OAAO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,EAAE,QAAQ,CAAC,CAAC;IAChE,CAAC;CACF;AAlED,4CAkEC;AAED,IAAA,yBAAa,EAAC,gBAAgB,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC"}
|
||||
270
node_modules/mongodb/lib/operations/indexes.js
generated
vendored
Normal file
270
node_modules/mongodb/lib/operations/indexes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IndexInformationOperation = exports.IndexExistsOperation = exports.ListIndexesOperation = exports.DropIndexesOperation = exports.DropIndexOperation = exports.EnsureIndexOperation = exports.CreateIndexOperation = exports.CreateIndexesOperation = exports.IndexesOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const common_functions_1 = require("./common_functions");
|
||||
const operation_1 = require("./operation");
|
||||
const VALID_INDEX_OPTIONS = new Set([
|
||||
'background',
|
||||
'unique',
|
||||
'name',
|
||||
'partialFilterExpression',
|
||||
'sparse',
|
||||
'hidden',
|
||||
'expireAfterSeconds',
|
||||
'storageEngine',
|
||||
'collation',
|
||||
'version',
|
||||
// text indexes
|
||||
'weights',
|
||||
'default_language',
|
||||
'language_override',
|
||||
'textIndexVersion',
|
||||
// 2d-sphere indexes
|
||||
'2dsphereIndexVersion',
|
||||
// 2d indexes
|
||||
'bits',
|
||||
'min',
|
||||
'max',
|
||||
// geoHaystack Indexes
|
||||
'bucketSize',
|
||||
// wildcard indexes
|
||||
'wildcardProjection'
|
||||
]);
|
||||
function isIndexDirection(x) {
|
||||
return (typeof x === 'number' || x === '2d' || x === '2dsphere' || x === 'text' || x === 'geoHaystack');
|
||||
}
|
||||
function isSingleIndexTuple(t) {
|
||||
return Array.isArray(t) && t.length === 2 && isIndexDirection(t[1]);
|
||||
}
|
||||
function makeIndexSpec(indexSpec, options) {
|
||||
const key = new Map();
|
||||
const indexSpecs = !Array.isArray(indexSpec) || isSingleIndexTuple(indexSpec) ? [indexSpec] : indexSpec;
|
||||
// Iterate through array and handle different types
|
||||
for (const spec of indexSpecs) {
|
||||
if (typeof spec === 'string') {
|
||||
key.set(spec, 1);
|
||||
}
|
||||
else if (Array.isArray(spec)) {
|
||||
key.set(spec[0], spec[1] ?? 1);
|
||||
}
|
||||
else if (spec instanceof Map) {
|
||||
for (const [property, value] of spec) {
|
||||
key.set(property, value);
|
||||
}
|
||||
}
|
||||
else if ((0, utils_1.isObject)(spec)) {
|
||||
for (const [property, value] of Object.entries(spec)) {
|
||||
key.set(property, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return { ...options, key };
|
||||
}
|
||||
/** @internal */
|
||||
class IndexesOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, options) {
|
||||
super(options);
|
||||
this.options = options;
|
||||
this.collection = collection;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const coll = this.collection;
|
||||
const options = this.options;
|
||||
(0, common_functions_1.indexInformation)(coll.s.db, coll.collectionName, { full: true, ...options, readPreference: this.readPreference, session }, callback);
|
||||
}
|
||||
}
|
||||
exports.IndexesOperation = IndexesOperation;
|
||||
/** @internal */
|
||||
class CreateIndexesOperation extends command_1.CommandOperation {
|
||||
constructor(parent, collectionName, indexes, options) {
|
||||
super(parent, options);
|
||||
this.options = options ?? {};
|
||||
this.collectionName = collectionName;
|
||||
this.indexes = indexes.map(userIndex => {
|
||||
// Ensure the key is a Map to preserve index key ordering
|
||||
const key = userIndex.key instanceof Map ? userIndex.key : new Map(Object.entries(userIndex.key));
|
||||
const name = userIndex.name != null ? userIndex.name : Array.from(key).flat().join('_');
|
||||
const validIndexOptions = Object.fromEntries(Object.entries({ ...userIndex }).filter(([optionName]) => VALID_INDEX_OPTIONS.has(optionName)));
|
||||
return {
|
||||
...validIndexOptions,
|
||||
name,
|
||||
key
|
||||
};
|
||||
});
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const options = this.options;
|
||||
const indexes = this.indexes;
|
||||
const serverWireVersion = (0, utils_1.maxWireVersion)(server);
|
||||
const cmd = { createIndexes: this.collectionName, indexes };
|
||||
if (options.commitQuorum != null) {
|
||||
if (serverWireVersion < 9) {
|
||||
callback(new error_1.MongoCompatibilityError('Option `commitQuorum` for `createIndexes` not supported on servers < 4.4'));
|
||||
return;
|
||||
}
|
||||
cmd.commitQuorum = options.commitQuorum;
|
||||
}
|
||||
// collation is set on each index, it should not be defined at the root
|
||||
this.options.collation = undefined;
|
||||
super.executeCommand(server, session, cmd, err => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
const indexNames = indexes.map(index => index.name || '');
|
||||
callback(undefined, indexNames);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CreateIndexesOperation = CreateIndexesOperation;
|
||||
/** @internal */
|
||||
class CreateIndexOperation extends CreateIndexesOperation {
|
||||
constructor(parent, collectionName, indexSpec, options) {
|
||||
super(parent, collectionName, [makeIndexSpec(indexSpec, options)], options);
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, (err, indexNames) => {
|
||||
if (err || !indexNames)
|
||||
return callback(err);
|
||||
return callback(undefined, indexNames[0]);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CreateIndexOperation = CreateIndexOperation;
|
||||
/** @internal */
|
||||
class EnsureIndexOperation extends CreateIndexOperation {
|
||||
constructor(db, collectionName, indexSpec, options) {
|
||||
super(db, collectionName, indexSpec, options);
|
||||
this.readPreference = read_preference_1.ReadPreference.primary;
|
||||
this.db = db;
|
||||
this.collectionName = collectionName;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const indexName = this.indexes[0].name;
|
||||
const cursor = this.db.collection(this.collectionName).listIndexes({ session });
|
||||
cursor.toArray().then(indexes => {
|
||||
indexes = Array.isArray(indexes) ? indexes : [indexes];
|
||||
if (indexes.some(index => index.name === indexName)) {
|
||||
callback(undefined, indexName);
|
||||
return;
|
||||
}
|
||||
super.execute(server, session, callback);
|
||||
}, error => {
|
||||
if (error instanceof error_1.MongoError && error.code === error_1.MONGODB_ERROR_CODES.NamespaceNotFound) {
|
||||
// ignore "NamespaceNotFound" errors
|
||||
return super.execute(server, session, callback);
|
||||
}
|
||||
return callback(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.EnsureIndexOperation = EnsureIndexOperation;
|
||||
/** @internal */
|
||||
class DropIndexOperation extends command_1.CommandOperation {
|
||||
constructor(collection, indexName, options) {
|
||||
super(collection, options);
|
||||
this.options = options ?? {};
|
||||
this.collection = collection;
|
||||
this.indexName = indexName;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const cmd = { dropIndexes: this.collection.collectionName, index: this.indexName };
|
||||
super.executeCommand(server, session, cmd, callback);
|
||||
}
|
||||
}
|
||||
exports.DropIndexOperation = DropIndexOperation;
|
||||
/** @internal */
|
||||
class DropIndexesOperation extends DropIndexOperation {
|
||||
constructor(collection, options) {
|
||||
super(collection, '*', options);
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, err => {
|
||||
if (err)
|
||||
return callback(err, false);
|
||||
callback(undefined, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.DropIndexesOperation = DropIndexesOperation;
|
||||
/** @internal */
|
||||
class ListIndexesOperation extends command_1.CommandOperation {
|
||||
constructor(collection, options) {
|
||||
super(collection, options);
|
||||
this.options = { ...options };
|
||||
delete this.options.writeConcern;
|
||||
this.collectionNamespace = collection.s.namespace;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const serverWireVersion = (0, utils_1.maxWireVersion)(server);
|
||||
const cursor = this.options.batchSize ? { batchSize: this.options.batchSize } : {};
|
||||
const command = { listIndexes: this.collectionNamespace.collection, cursor };
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (serverWireVersion >= 9 && this.options.comment !== undefined) {
|
||||
command.comment = this.options.comment;
|
||||
}
|
||||
super.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.ListIndexesOperation = ListIndexesOperation;
|
||||
/** @internal */
|
||||
class IndexExistsOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, indexes, options) {
|
||||
super(options);
|
||||
this.options = options;
|
||||
this.collection = collection;
|
||||
this.indexes = indexes;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const coll = this.collection;
|
||||
const indexes = this.indexes;
|
||||
(0, common_functions_1.indexInformation)(coll.s.db, coll.collectionName, { ...this.options, readPreference: this.readPreference, session }, (err, indexInformation) => {
|
||||
// If we have an error return
|
||||
if (err != null)
|
||||
return callback(err);
|
||||
// Let's check for the index names
|
||||
if (!Array.isArray(indexes))
|
||||
return callback(undefined, indexInformation[indexes] != null);
|
||||
// Check in list of indexes
|
||||
for (let i = 0; i < indexes.length; i++) {
|
||||
if (indexInformation[indexes[i]] == null) {
|
||||
return callback(undefined, false);
|
||||
}
|
||||
}
|
||||
// All keys found return true
|
||||
return callback(undefined, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.IndexExistsOperation = IndexExistsOperation;
|
||||
/** @internal */
|
||||
class IndexInformationOperation extends operation_1.AbstractOperation {
|
||||
constructor(db, name, options) {
|
||||
super(options);
|
||||
this.options = options ?? {};
|
||||
this.db = db;
|
||||
this.name = name;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const db = this.db;
|
||||
const name = this.name;
|
||||
(0, common_functions_1.indexInformation)(db, name, { ...this.options, readPreference: this.readPreference, session }, callback);
|
||||
}
|
||||
}
|
||||
exports.IndexInformationOperation = IndexInformationOperation;
|
||||
(0, operation_1.defineAspects)(ListIndexesOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING
|
||||
]);
|
||||
(0, operation_1.defineAspects)(CreateIndexesOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(CreateIndexOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(EnsureIndexOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(DropIndexOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(DropIndexesOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=indexes.js.map
|
||||
1
node_modules/mongodb/lib/operations/indexes.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/indexes.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
95
node_modules/mongodb/lib/operations/insert.js
generated
vendored
Normal file
95
node_modules/mongodb/lib/operations/insert.js
generated
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InsertManyOperation = exports.InsertOneOperation = exports.InsertOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const write_concern_1 = require("../write_concern");
|
||||
const bulk_write_1 = require("./bulk_write");
|
||||
const command_1 = require("./command");
|
||||
const common_functions_1 = require("./common_functions");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class InsertOperation extends command_1.CommandOperation {
|
||||
constructor(ns, documents, options) {
|
||||
super(undefined, options);
|
||||
this.options = { ...options, checkKeys: options.checkKeys ?? false };
|
||||
this.ns = ns;
|
||||
this.documents = documents;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const options = this.options ?? {};
|
||||
const ordered = typeof options.ordered === 'boolean' ? options.ordered : true;
|
||||
const command = {
|
||||
insert: this.ns.collection,
|
||||
documents: this.documents,
|
||||
ordered
|
||||
};
|
||||
if (typeof options.bypassDocumentValidation === 'boolean') {
|
||||
command.bypassDocumentValidation = options.bypassDocumentValidation;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
super.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.InsertOperation = InsertOperation;
|
||||
class InsertOneOperation extends InsertOperation {
|
||||
constructor(collection, doc, options) {
|
||||
super(collection.s.namespace, (0, common_functions_1.prepareDocs)(collection, [doc], options), options);
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, (err, res) => {
|
||||
if (err || res == null)
|
||||
return callback(err);
|
||||
if (res.code)
|
||||
return callback(new error_1.MongoServerError(res));
|
||||
if (res.writeErrors) {
|
||||
// This should be a WriteError but we can't change it now because of error hierarchy
|
||||
return callback(new error_1.MongoServerError(res.writeErrors[0]));
|
||||
}
|
||||
callback(undefined, {
|
||||
acknowledged: this.writeConcern?.w !== 0 ?? true,
|
||||
insertedId: this.documents[0]._id
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.InsertOneOperation = InsertOneOperation;
|
||||
/** @internal */
|
||||
class InsertManyOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, docs, options) {
|
||||
super(options);
|
||||
if (!Array.isArray(docs)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "docs" must be an array of documents');
|
||||
}
|
||||
this.options = options;
|
||||
this.collection = collection;
|
||||
this.docs = docs;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const coll = this.collection;
|
||||
const options = { ...this.options, ...this.bsonOptions, readPreference: this.readPreference };
|
||||
const writeConcern = write_concern_1.WriteConcern.fromOptions(options);
|
||||
const bulkWriteOperation = new bulk_write_1.BulkWriteOperation(coll, (0, common_functions_1.prepareDocs)(coll, this.docs, options).map(document => ({ insertOne: { document } })), options);
|
||||
bulkWriteOperation.execute(server, session, (err, res) => {
|
||||
if (err || res == null) {
|
||||
if (err && err.message === 'Operation must be an object with an operation key') {
|
||||
err = new error_1.MongoInvalidArgumentError('Collection.insertMany() cannot be called with an array that has null/undefined values');
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
callback(undefined, {
|
||||
acknowledged: writeConcern?.w !== 0 ?? true,
|
||||
insertedCount: res.insertedCount,
|
||||
insertedIds: res.insertedIds
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.InsertManyOperation = InsertManyOperation;
|
||||
(0, operation_1.defineAspects)(InsertOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(InsertOneOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(InsertManyOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=insert.js.map
|
||||
1
node_modules/mongodb/lib/operations/insert.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/insert.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"insert.js","sourceRoot":"","sources":["../../src/operations/insert.ts"],"names":[],"mappings":";;;AAGA,oCAAuE;AAKvE,oDAAgD;AAChD,6CAAkD;AAClD,uCAAsE;AACtE,yDAAiD;AACjD,2CAAuE;AAEvE,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,0BAA0B;IAI7D,YAAY,EAAoB,EAAE,SAAqB,EAAE,OAAyB;QAChF,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK,EAAE,CAAC;QACrE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA4B;QAE5B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,OAAO,KAAK,SAAS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C,CAAC,EACpF,OAAO,CACR,CAAC;QAEF,kBAAkB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACvD,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,EAAE;gBACtB,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,KAAK,mDAAmD,EAAE;oBAC9E,GAAG,GAAG,IAAI,iCAAyB,CACjC,uFAAuF,CACxF,CAAC;iBACH;gBACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;aACtB;YACD,QAAQ,CAAC,SAAS,EAAE;gBAClB,YAAY,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI;gBAC3C,aAAa,EAAE,GAAG,CAAC,aAAa;gBAChC,WAAW,EAAE,GAAG,CAAC,WAAW;aAC7B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA/CD,kDA+CC;AAED,IAAA,yBAAa,EAAC,eAAe,EAAE,CAAC,kBAAM,CAAC,SAAS,EAAE,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AAC3E,IAAA,yBAAa,EAAC,kBAAkB,EAAE,CAAC,kBAAM,CAAC,SAAS,EAAE,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AAC9E,IAAA,yBAAa,EAAC,mBAAmB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
28
node_modules/mongodb/lib/operations/is_capped.js
generated
vendored
Normal file
28
node_modules/mongodb/lib/operations/is_capped.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IsCappedOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class IsCappedOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, options) {
|
||||
super(options);
|
||||
this.options = options;
|
||||
this.collection = collection;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const coll = this.collection;
|
||||
coll.s.db
|
||||
.listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session })
|
||||
.toArray()
|
||||
.then(collections => {
|
||||
if (collections.length === 0) {
|
||||
// TODO(NODE-3485)
|
||||
return callback(new error_1.MongoAPIError(`collection ${coll.namespace} not found`));
|
||||
}
|
||||
callback(undefined, !!collections[0].options?.capped);
|
||||
}, error => callback(error));
|
||||
}
|
||||
}
|
||||
exports.IsCappedOperation = IsCappedOperation;
|
||||
//# sourceMappingURL=is_capped.js.map
|
||||
1
node_modules/mongodb/lib/operations/is_capped.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/is_capped.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"is_capped.js","sourceRoot":"","sources":["../../src/operations/is_capped.ts"],"names":[],"mappings":";;;AACA,oCAAyC;AAIzC,2CAAkE;AAElE,gBAAgB;AAChB,MAAa,iBAAkB,SAAQ,6BAA0B;IAI/D,YAAY,UAAsB,EAAE,OAAyB;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA2B;QAE3B,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAE7B,IAAI,CAAC,CAAC,CAAC,EAAE;aACN,eAAe,CACd,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,EAC7B,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CACnF;aACA,OAAO,EAAE;aACT,IAAI,CACH,WAAW,CAAC,EAAE;YACZ,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC5B,kBAAkB;gBAClB,OAAO,QAAQ,CAAC,IAAI,qBAAa,CAAC,cAAc,IAAI,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC;aAC9E;YAED,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC,EACD,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzB,CAAC;IACN,CAAC;CACF;AAnCD,8CAmCC"}
|
||||
32
node_modules/mongodb/lib/operations/kill_cursors.js
generated
vendored
Normal file
32
node_modules/mongodb/lib/operations/kill_cursors.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.KillCursorsOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const operation_1 = require("./operation");
|
||||
class KillCursorsOperation extends operation_1.AbstractOperation {
|
||||
constructor(cursorId, ns, server, options) {
|
||||
super(options);
|
||||
this.ns = ns;
|
||||
this.cursorId = cursorId;
|
||||
this.server = server;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
if (server !== this.server) {
|
||||
return callback(new error_1.MongoRuntimeError('Killcursor must run on the same server operation began on'));
|
||||
}
|
||||
const killCursors = this.ns.collection;
|
||||
if (killCursors == null) {
|
||||
// Cursors should have adopted the namespace returned by MongoDB
|
||||
// which should always defined a collection name (even a pseudo one, ex. db.aggregate())
|
||||
return callback(new error_1.MongoRuntimeError('A collection name must be determined before killCursors'));
|
||||
}
|
||||
const killCursorsCommand = {
|
||||
killCursors,
|
||||
cursors: [this.cursorId]
|
||||
};
|
||||
server.command(this.ns, killCursorsCommand, { session }, () => callback());
|
||||
}
|
||||
}
|
||||
exports.KillCursorsOperation = KillCursorsOperation;
|
||||
(0, operation_1.defineAspects)(KillCursorsOperation, [operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
|
||||
//# sourceMappingURL=kill_cursors.js.map
|
||||
1
node_modules/mongodb/lib/operations/kill_cursors.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/kill_cursors.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"kill_cursors.js","sourceRoot":"","sources":["../../src/operations/kill_cursors.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAI7C,2CAAyF;AAYzF,MAAa,oBAAqB,SAAQ,6BAAiB;IAGzD,YAAY,QAAc,EAAE,EAAoB,EAAE,MAAc,EAAE,OAAyB;QACzF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,MAAc,EAAE,OAAkC,EAAE,QAAwB;QAClF,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;YAC1B,OAAO,QAAQ,CACb,IAAI,yBAAiB,CAAC,2DAA2D,CAAC,CACnF,CAAC;SACH;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC;QACvC,IAAI,WAAW,IAAI,IAAI,EAAE;YACvB,gEAAgE;YAChE,wFAAwF;YACxF,OAAO,QAAQ,CACb,IAAI,yBAAiB,CAAC,yDAAyD,CAAC,CACjF,CAAC;SACH;QAED,MAAM,kBAAkB,GAAuB;YAC7C,WAAW;YACX,OAAO,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC7E,CAAC;CACF;AAjCD,oDAiCC;AAED,IAAA,yBAAa,EAAC,oBAAoB,EAAE,CAAC,kBAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC"}
|
||||
47
node_modules/mongodb/lib/operations/list_collections.js
generated
vendored
Normal file
47
node_modules/mongodb/lib/operations/list_collections.js
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ListCollectionsOperation = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class ListCollectionsOperation extends command_1.CommandOperation {
|
||||
constructor(db, filter, options) {
|
||||
super(db, options);
|
||||
this.options = { ...options };
|
||||
delete this.options.writeConcern;
|
||||
this.db = db;
|
||||
this.filter = filter;
|
||||
this.nameOnly = !!this.options.nameOnly;
|
||||
this.authorizedCollections = !!this.options.authorizedCollections;
|
||||
if (typeof this.options.batchSize === 'number') {
|
||||
this.batchSize = this.options.batchSize;
|
||||
}
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
return super.executeCommand(server, session, this.generateCommand((0, utils_1.maxWireVersion)(server)), callback);
|
||||
}
|
||||
/* This is here for the purpose of unit testing the final command that gets sent. */
|
||||
generateCommand(wireVersion) {
|
||||
const command = {
|
||||
listCollections: 1,
|
||||
filter: this.filter,
|
||||
cursor: this.batchSize ? { batchSize: this.batchSize } : {},
|
||||
nameOnly: this.nameOnly,
|
||||
authorizedCollections: this.authorizedCollections
|
||||
};
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (wireVersion >= 9 && this.options.comment !== undefined) {
|
||||
command.comment = this.options.comment;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
exports.ListCollectionsOperation = ListCollectionsOperation;
|
||||
(0, operation_1.defineAspects)(ListCollectionsOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING
|
||||
]);
|
||||
//# sourceMappingURL=list_collections.js.map
|
||||
1
node_modules/mongodb/lib/operations/list_collections.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/list_collections.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"list_collections.js","sourceRoot":"","sources":["../../src/operations/list_collections.ts"],"names":[],"mappings":";;;AAIA,oCAAoD;AACpD,uCAAsE;AACtE,2CAAoD;AAYpD,gBAAgB;AAChB,MAAa,wBAAyB,SAAQ,0BAA0B;IAetE,YAAY,EAAM,EAAE,MAAgB,EAAE,OAAgC;QACpE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEnB,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QAElE,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE;YAC9C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;SACzC;IACH,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA4B;QAE5B,OAAO,KAAK,CAAC,cAAc,CACzB,MAAM,EACN,OAAO,EACP,IAAI,CAAC,eAAe,CAAC,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAC,EAC5C,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,oFAAoF;IACpF,eAAe,CAAC,WAAmB;QACjC,MAAM,OAAO,GAAa;YACxB,eAAe,EAAE,CAAC;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE;YAC3D,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;SAClD,CAAC;QAEF,iEAAiE;QACjE,gDAAgD;QAChD,IAAI,WAAW,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;YAC1D,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SACxC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA7DD,4DA6DC;AAcD,IAAA,yBAAa,EAAC,wBAAwB,EAAE;IACtC,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;CACvB,CAAC,CAAC"}
|
||||
35
node_modules/mongodb/lib/operations/list_databases.js
generated
vendored
Normal file
35
node_modules/mongodb/lib/operations/list_databases.js
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ListDatabasesOperation = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class ListDatabasesOperation extends command_1.CommandOperation {
|
||||
constructor(db, options) {
|
||||
super(db, options);
|
||||
this.options = options ?? {};
|
||||
this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const cmd = { listDatabases: 1 };
|
||||
if (this.options.nameOnly) {
|
||||
cmd.nameOnly = Number(cmd.nameOnly);
|
||||
}
|
||||
if (this.options.filter) {
|
||||
cmd.filter = this.options.filter;
|
||||
}
|
||||
if (typeof this.options.authorizedDatabases === 'boolean') {
|
||||
cmd.authorizedDatabases = this.options.authorizedDatabases;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if ((0, utils_1.maxWireVersion)(server) >= 9 && this.options.comment !== undefined) {
|
||||
cmd.comment = this.options.comment;
|
||||
}
|
||||
super.executeCommand(server, session, cmd, callback);
|
||||
}
|
||||
}
|
||||
exports.ListDatabasesOperation = ListDatabasesOperation;
|
||||
(0, operation_1.defineAspects)(ListDatabasesOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE]);
|
||||
//# sourceMappingURL=list_databases.js.map
|
||||
1
node_modules/mongodb/lib/operations/list_databases.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/list_databases.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"list_databases.js","sourceRoot":"","sources":["../../src/operations/list_databases.ts"],"names":[],"mappings":";;;AAIA,oCAAsE;AACtE,uCAAsE;AACtE,2CAAoD;AAoBpD,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,0BAAqC;IAG/E,YAAY,EAAM,EAAE,OAA8B;QAChD,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,EAAE,GAAG,IAAI,wBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAAuC;QAEvC,MAAM,GAAG,GAAa,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;QAC3C,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YACzB,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SACrC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACvB,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;SAClC;QAED,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,KAAK,SAAS,EAAE;YACzD,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;SAC5D;QAED,iEAAiE;QACjE,gDAAgD;QAChD,IAAI,IAAA,sBAAc,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;YACrE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SACpC;QAED,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;CACF;AAnCD,wDAmCC;AAED,IAAA,yBAAa,EAAC,sBAAsB,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
||||
73
node_modules/mongodb/lib/operations/operation.js
generated
vendored
Normal file
73
node_modules/mongodb/lib/operations/operation.js
generated
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defineAspects = exports.AbstractOperation = exports.Aspect = void 0;
|
||||
const util_1 = require("util");
|
||||
const bson_1 = require("../bson");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
exports.Aspect = {
|
||||
READ_OPERATION: Symbol('READ_OPERATION'),
|
||||
WRITE_OPERATION: Symbol('WRITE_OPERATION'),
|
||||
RETRYABLE: Symbol('RETRYABLE'),
|
||||
EXPLAINABLE: Symbol('EXPLAINABLE'),
|
||||
SKIP_COLLATION: Symbol('SKIP_COLLATION'),
|
||||
CURSOR_CREATING: Symbol('CURSOR_CREATING'),
|
||||
MUST_SELECT_SAME_SERVER: Symbol('MUST_SELECT_SAME_SERVER')
|
||||
};
|
||||
/** @internal */
|
||||
const kSession = Symbol('session');
|
||||
/**
|
||||
* This class acts as a parent class for any operation and is responsible for setting this.options,
|
||||
* as well as setting and getting a session.
|
||||
* Additionally, this class implements `hasAspect`, which determines whether an operation has
|
||||
* a specific aspect.
|
||||
* @internal
|
||||
*/
|
||||
class AbstractOperation {
|
||||
constructor(options = {}) {
|
||||
this.executeAsync = (0, util_1.promisify)((server, session, callback) => {
|
||||
this.execute(server, session, callback);
|
||||
});
|
||||
this.readPreference = this.hasAspect(exports.Aspect.WRITE_OPERATION)
|
||||
? read_preference_1.ReadPreference.primary
|
||||
: read_preference_1.ReadPreference.fromOptions(options) ?? read_preference_1.ReadPreference.primary;
|
||||
// Pull the BSON serialize options from the already-resolved options
|
||||
this.bsonOptions = (0, bson_1.resolveBSONOptions)(options);
|
||||
this[kSession] = options.session != null ? options.session : undefined;
|
||||
this.options = options;
|
||||
this.bypassPinningCheck = !!options.bypassPinningCheck;
|
||||
this.trySecondaryWrite = false;
|
||||
}
|
||||
hasAspect(aspect) {
|
||||
const ctor = this.constructor;
|
||||
if (ctor.aspects == null) {
|
||||
return false;
|
||||
}
|
||||
return ctor.aspects.has(aspect);
|
||||
}
|
||||
get session() {
|
||||
return this[kSession];
|
||||
}
|
||||
clearSession() {
|
||||
this[kSession] = undefined;
|
||||
}
|
||||
get canRetryRead() {
|
||||
return true;
|
||||
}
|
||||
get canRetryWrite() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.AbstractOperation = AbstractOperation;
|
||||
function defineAspects(operation, aspects) {
|
||||
if (!Array.isArray(aspects) && !(aspects instanceof Set)) {
|
||||
aspects = [aspects];
|
||||
}
|
||||
aspects = new Set(aspects);
|
||||
Object.defineProperty(operation, 'aspects', {
|
||||
value: aspects,
|
||||
writable: false
|
||||
});
|
||||
return aspects;
|
||||
}
|
||||
exports.defineAspects = defineAspects;
|
||||
//# sourceMappingURL=operation.js.map
|
||||
1
node_modules/mongodb/lib/operations/operation.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/operation.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/operations/operation.ts"],"names":[],"mappings":";;;AAAA,+BAAiC;AAEjC,kCAA6E;AAC7E,wDAAwE;AAK3D,QAAA,MAAM,GAAG;IACpB,cAAc,EAAE,MAAM,CAAC,gBAAgB,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC;IAClC,cAAc,EAAE,MAAM,CAAC,gBAAgB,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC;IAC1C,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CAAC;CAClD,CAAC;AAuBX,gBAAgB;AAChB,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAEnC;;;;;;GAMG;AACH,MAAsB,iBAAiB;IAiBrC,YAAY,UAA4B,EAAE;QACxC,IAAI,CAAC,YAAY,GAAG,IAAA,gBAAS,EAC3B,CACE,MAAc,EACd,OAAkC,EAClC,QAAwC,EACxC,EAAE;YACF,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,QAAe,CAAC,CAAC;QACjD,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,cAAM,CAAC,eAAe,CAAC;YAC1D,CAAC,CAAC,gCAAc,CAAC,OAAO;YACxB,CAAC,CAAC,gCAAc,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,gCAAc,CAAC,OAAO,CAAC;QAElE,oEAAoE;QACpE,IAAI,CAAC,WAAW,GAAG,IAAA,yBAAkB,EAAC,OAAO,CAAC,CAAC;QAE/C,IAAI,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QAEvE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACvD,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACjC,CAAC;IAQD,SAAS,CAAC,MAAc;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAmC,CAAC;QACtD,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IAED,YAAY;QACV,IAAI,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxED,8CAwEC;AAED,SAAgB,aAAa,CAC3B,SAA+B,EAC/B,OAAwC;IAExC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,YAAY,GAAG,CAAC,EAAE;QACxD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;KACrB;IAED,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3B,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE;QAC1C,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAfD,sCAeC"}
|
||||
28
node_modules/mongodb/lib/operations/options_operation.js
generated
vendored
Normal file
28
node_modules/mongodb/lib/operations/options_operation.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OptionsOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class OptionsOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, options) {
|
||||
super(options);
|
||||
this.options = options;
|
||||
this.collection = collection;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const coll = this.collection;
|
||||
coll.s.db
|
||||
.listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session })
|
||||
.toArray()
|
||||
.then(collections => {
|
||||
if (collections.length === 0) {
|
||||
// TODO(NODE-3485)
|
||||
return callback(new error_1.MongoAPIError(`collection ${coll.namespace} not found`));
|
||||
}
|
||||
callback(undefined, collections[0].options);
|
||||
}, error => callback(error));
|
||||
}
|
||||
}
|
||||
exports.OptionsOperation = OptionsOperation;
|
||||
//# sourceMappingURL=options_operation.js.map
|
||||
1
node_modules/mongodb/lib/operations/options_operation.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/options_operation.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"options_operation.js","sourceRoot":"","sources":["../../src/operations/options_operation.ts"],"names":[],"mappings":";;;AAEA,oCAAyC;AAIzC,2CAAkE;AAElE,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,6BAA2B;IAI/D,YAAY,UAAsB,EAAE,OAAyB;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA4B;QAE5B,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAE7B,IAAI,CAAC,CAAC,CAAC,EAAE;aACN,eAAe,CACd,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,EAC7B,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CACnF;aACA,OAAO,EAAE;aACT,IAAI,CACH,WAAW,CAAC,EAAE;YACZ,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC5B,kBAAkB;gBAClB,OAAO,QAAQ,CAAC,IAAI,qBAAa,CAAC,cAAc,IAAI,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC;aAC9E;YAED,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC,EACD,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzB,CAAC;IACN,CAAC;CACF;AAnCD,4CAmCC"}
|
||||
33
node_modules/mongodb/lib/operations/profiling_level.js
generated
vendored
Normal file
33
node_modules/mongodb/lib/operations/profiling_level.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ProfilingLevelOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const command_1 = require("./command");
|
||||
/** @internal */
|
||||
class ProfilingLevelOperation extends command_1.CommandOperation {
|
||||
constructor(db, options) {
|
||||
super(db, options);
|
||||
this.options = options;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.executeCommand(server, session, { profile: -1 }, (err, doc) => {
|
||||
if (err == null && doc.ok === 1) {
|
||||
const was = doc.was;
|
||||
if (was === 0)
|
||||
return callback(undefined, 'off');
|
||||
if (was === 1)
|
||||
return callback(undefined, 'slow_only');
|
||||
if (was === 2)
|
||||
return callback(undefined, 'all');
|
||||
// TODO(NODE-3483)
|
||||
return callback(new error_1.MongoRuntimeError(`Illegal profiling level value ${was}`));
|
||||
}
|
||||
else {
|
||||
// TODO(NODE-3483): Consider MongoUnexpectedServerResponseError
|
||||
err != null ? callback(err) : callback(new error_1.MongoRuntimeError('Error with profile command'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ProfilingLevelOperation = ProfilingLevelOperation;
|
||||
//# sourceMappingURL=profiling_level.js.map
|
||||
1
node_modules/mongodb/lib/operations/profiling_level.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/profiling_level.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"profiling_level.js","sourceRoot":"","sources":["../../src/operations/profiling_level.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAI7C,uCAAsE;AAKtE,gBAAgB;AAChB,MAAa,uBAAwB,SAAQ,0BAAwB;IAGnE,YAAY,EAAM,EAAE,OAA8B;QAChD,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA0B;QAE1B,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAClE,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,EAAE,KAAK,CAAC,EAAE;gBAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;gBACpB,IAAI,GAAG,KAAK,CAAC;oBAAE,OAAO,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBACjD,IAAI,GAAG,KAAK,CAAC;oBAAE,OAAO,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;gBACvD,IAAI,GAAG,KAAK,CAAC;oBAAE,OAAO,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBACjD,kBAAkB;gBAClB,OAAO,QAAQ,CAAC,IAAI,yBAAiB,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC,CAAC;aAChF;iBAAM;gBACL,+DAA+D;gBAC/D,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,yBAAiB,CAAC,4BAA4B,CAAC,CAAC,CAAC;aAC7F;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3BD,0DA2BC"}
|
||||
21
node_modules/mongodb/lib/operations/remove_user.js
generated
vendored
Normal file
21
node_modules/mongodb/lib/operations/remove_user.js
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RemoveUserOperation = void 0;
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class RemoveUserOperation extends command_1.CommandOperation {
|
||||
constructor(db, username, options) {
|
||||
super(db, options);
|
||||
this.options = options;
|
||||
this.username = username;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.executeCommand(server, session, { dropUser: this.username }, err => {
|
||||
callback(err, err ? false : true);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.RemoveUserOperation = RemoveUserOperation;
|
||||
(0, operation_1.defineAspects)(RemoveUserOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=remove_user.js.map
|
||||
1
node_modules/mongodb/lib/operations/remove_user.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/remove_user.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"remove_user.js","sourceRoot":"","sources":["../../src/operations/remove_user.ts"],"names":[],"mappings":";;;AAIA,uCAAsE;AACtE,2CAAoD;AAKpD,gBAAgB;AAChB,MAAa,mBAAoB,SAAQ,0BAAyB;IAIhE,YAAY,EAAM,EAAE,QAAgB,EAAE,OAA0B;QAC9D,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA2B;QAE3B,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,EAAE;YACvE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,kDAmBC;AAED,IAAA,yBAAa,EAAC,mBAAmB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
46
node_modules/mongodb/lib/operations/rename.js
generated
vendored
Normal file
46
node_modules/mongodb/lib/operations/rename.js
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"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
|
||||
1
node_modules/mongodb/lib/operations/rename.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/rename.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../../src/operations/rename.ts"],"names":[],"mappings":";;;AACA,8CAA2C;AAC3C,oCAA4C;AAG5C,oCAAyD;AAEzD,2CAAoD;AACpD,+CAAyD;AAUzD,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,sCAAwB;IAK3D,YAAY,UAAsB,EAAE,OAAe,EAAE,OAAsB;QACzE,4BAA4B;QAC5B,IAAA,2BAAmB,EAAC,OAAO,CAAC,CAAC;QAE7B,oBAAoB;QACpB,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC;QAC9C,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC/E,MAAM,UAAU,GAAG,OAAO,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;QACxF,MAAM,GAAG,GAAG,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;QAE7F,KAAK,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA8B;QAE9B,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAE7B,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC1C,IAAI,GAAG;gBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC9B,mBAAmB;YACnB,IAAI,GAAG,EAAE,MAAM,EAAE;gBACf,OAAO,QAAQ,CAAC,IAAI,wBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;aAC5C;YAED,IAAI,OAA6B,CAAC;YAClC,IAAI;gBACF,OAAO,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;aACnE;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;aACtB;YAED,OAAO,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7CD,0CA6CC;AAED,IAAA,yBAAa,EAAC,eAAe,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
26
node_modules/mongodb/lib/operations/run_command.js
generated
vendored
Normal file
26
node_modules/mongodb/lib/operations/run_command.js
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RunAdminCommandOperation = exports.RunCommandOperation = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
/** @internal */
|
||||
class RunCommandOperation extends command_1.CommandOperation {
|
||||
constructor(parent, command, options) {
|
||||
super(parent, options);
|
||||
this.options = options ?? {};
|
||||
this.command = command;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const command = this.command;
|
||||
this.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.RunCommandOperation = RunCommandOperation;
|
||||
class RunAdminCommandOperation extends RunCommandOperation {
|
||||
constructor(parent, command, options) {
|
||||
super(parent, command, options);
|
||||
this.ns = new utils_1.MongoDBNamespace('admin');
|
||||
}
|
||||
}
|
||||
exports.RunAdminCommandOperation = RunAdminCommandOperation;
|
||||
//# sourceMappingURL=run_command.js.map
|
||||
1
node_modules/mongodb/lib/operations/run_command.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/run_command.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"run_command.js","sourceRoot":"","sources":["../../src/operations/run_command.ts"],"names":[],"mappings":";;;AAGA,oCAAsD;AACtD,uCAAuF;AAKvF,gBAAgB;AAChB,MAAa,mBAAkC,SAAQ,0BAAmB;IAIxE,YAAY,MAAmC,EAAE,OAAiB,EAAE,OAA2B;QAC7F,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAAqB;QAErB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC1D,CAAC;CACF;AAlBD,kDAkBC;AAED,MAAa,wBAAuC,SAAQ,mBAAsB;IAChF,YAAY,MAAmC,EAAE,OAAiB,EAAE,OAA2B;QAC7F,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC,EAAE,GAAG,IAAI,wBAAgB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF;AALD,4DAKC"}
|
||||
51
node_modules/mongodb/lib/operations/set_profiling_level.js
generated
vendored
Normal file
51
node_modules/mongodb/lib/operations/set_profiling_level.js
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SetProfilingLevelOperation = exports.ProfilingLevel = void 0;
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const levelValues = new Set(['off', 'slow_only', 'all']);
|
||||
/** @public */
|
||||
exports.ProfilingLevel = Object.freeze({
|
||||
off: 'off',
|
||||
slowOnly: 'slow_only',
|
||||
all: 'all'
|
||||
});
|
||||
/** @internal */
|
||||
class SetProfilingLevelOperation extends command_1.CommandOperation {
|
||||
constructor(db, level, options) {
|
||||
super(db, options);
|
||||
this.options = options;
|
||||
switch (level) {
|
||||
case exports.ProfilingLevel.off:
|
||||
this.profile = 0;
|
||||
break;
|
||||
case exports.ProfilingLevel.slowOnly:
|
||||
this.profile = 1;
|
||||
break;
|
||||
case exports.ProfilingLevel.all:
|
||||
this.profile = 2;
|
||||
break;
|
||||
default:
|
||||
this.profile = 0;
|
||||
break;
|
||||
}
|
||||
this.level = level;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const level = this.level;
|
||||
if (!levelValues.has(level)) {
|
||||
return callback(new error_1.MongoInvalidArgumentError(`Profiling level must be one of "${(0, utils_1.enumToString)(exports.ProfilingLevel)}"`));
|
||||
}
|
||||
// TODO(NODE-3483): Determine error to put here
|
||||
super.executeCommand(server, session, { profile: this.profile }, (err, doc) => {
|
||||
if (err == null && doc.ok === 1)
|
||||
return callback(undefined, level);
|
||||
return err != null
|
||||
? callback(err)
|
||||
: callback(new error_1.MongoRuntimeError('Error with profile command'));
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.SetProfilingLevelOperation = SetProfilingLevelOperation;
|
||||
//# sourceMappingURL=set_profiling_level.js.map
|
||||
1
node_modules/mongodb/lib/operations/set_profiling_level.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/set_profiling_level.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"set_profiling_level.js","sourceRoot":"","sources":["../../src/operations/set_profiling_level.ts"],"names":[],"mappings":";;;AACA,oCAAwE;AAIxE,oCAAwC;AACxC,uCAAsE;AAEtE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;AAEzD,cAAc;AACD,QAAA,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,GAAG,EAAE,KAAK;IACV,QAAQ,EAAE,WAAW;IACrB,GAAG,EAAE,KAAK;CACF,CAAC,CAAC;AAQZ,gBAAgB;AAChB,MAAa,0BAA2B,SAAQ,0BAAgC;IAK9E,YAAY,EAAM,EAAE,KAAqB,EAAE,OAAiC;QAC1E,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,QAAQ,KAAK,EAAE;YACb,KAAK,sBAAc,CAAC,GAAG;gBACrB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;gBACjB,MAAM;YACR,KAAK,sBAAc,CAAC,QAAQ;gBAC1B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;gBACjB,MAAM;YACR,KAAK,sBAAc,CAAC,GAAG;gBACrB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;gBACjB,MAAM;YACR;gBACE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;gBACjB,MAAM;SACT;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAAkC;QAElC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAEzB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,QAAQ,CACb,IAAI,iCAAyB,CAC3B,mCAAmC,IAAA,oBAAY,EAAC,sBAAc,CAAC,GAAG,CACnE,CACF,CAAC;SACH;QAED,+CAA+C;QAC/C,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC5E,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,EAAE,KAAK,CAAC;gBAAE,OAAO,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YACnE,OAAO,GAAG,IAAI,IAAI;gBAChB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;gBACf,CAAC,CAAC,QAAQ,CAAC,IAAI,yBAAiB,CAAC,4BAA4B,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjDD,gEAiDC"}
|
||||
48
node_modules/mongodb/lib/operations/stats.js
generated
vendored
Normal file
48
node_modules/mongodb/lib/operations/stats.js
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DbStatsOperation = exports.CollStatsOperation = void 0;
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/**
|
||||
* Get all the collection statistics.
|
||||
* @internal
|
||||
*/
|
||||
class CollStatsOperation extends command_1.CommandOperation {
|
||||
/**
|
||||
* Construct a Stats operation.
|
||||
*
|
||||
* @param collection - Collection instance
|
||||
* @param options - Optional settings. See Collection.prototype.stats for a list of options.
|
||||
*/
|
||||
constructor(collection, options) {
|
||||
super(collection, options);
|
||||
this.options = options ?? {};
|
||||
this.collectionName = collection.collectionName;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const command = { collStats: this.collectionName };
|
||||
if (this.options.scale != null) {
|
||||
command.scale = this.options.scale;
|
||||
}
|
||||
super.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.CollStatsOperation = CollStatsOperation;
|
||||
/** @internal */
|
||||
class DbStatsOperation extends command_1.CommandOperation {
|
||||
constructor(db, options) {
|
||||
super(db, options);
|
||||
this.options = options;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const command = { dbStats: true };
|
||||
if (this.options.scale != null) {
|
||||
command.scale = this.options.scale;
|
||||
}
|
||||
super.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.DbStatsOperation = DbStatsOperation;
|
||||
(0, operation_1.defineAspects)(CollStatsOperation, [operation_1.Aspect.READ_OPERATION]);
|
||||
(0, operation_1.defineAspects)(DbStatsOperation, [operation_1.Aspect.READ_OPERATION]);
|
||||
//# sourceMappingURL=stats.js.map
|
||||
1
node_modules/mongodb/lib/operations/stats.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/stats.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/operations/stats.ts"],"names":[],"mappings":";;;AAMA,uCAAsE;AACtE,2CAAoD;AAQpD;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,0BAA0B;IAIhE;;;;;OAKG;IACH,YAAY,UAAsB,EAAE,OAA0B;QAC5D,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;IAClD,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA6B;QAE7B,MAAM,OAAO,GAAa,EAAE,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7D,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;YAC9B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;SACpC;QAED,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF;AA5BD,gDA4BC;AAQD,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,0BAA0B;IAG9D,YAAY,EAAM,EAAE,OAAuB;QACzC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,OAAkC,EAClC,QAA4B;QAE5B,MAAM,OAAO,GAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;YAC9B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;SACpC;QAED,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF;AApBD,4CAoBC;AAiMD,IAAA,yBAAa,EAAC,kBAAkB,EAAE,CAAC,kBAAM,CAAC,cAAc,CAAC,CAAC,CAAC;AAC3D,IAAA,yBAAa,EAAC,gBAAgB,EAAE,CAAC,kBAAM,CAAC,cAAc,CAAC,CAAC,CAAC"}
|
||||
183
node_modules/mongodb/lib/operations/update.js
generated
vendored
Normal file
183
node_modules/mongodb/lib/operations/update.js
generated
vendored
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeUpdateStatement = exports.ReplaceOneOperation = exports.UpdateManyOperation = exports.UpdateOneOperation = exports.UpdateOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class UpdateOperation extends command_1.CommandOperation {
|
||||
constructor(ns, statements, options) {
|
||||
super(undefined, options);
|
||||
this.options = options;
|
||||
this.ns = ns;
|
||||
this.statements = statements;
|
||||
}
|
||||
get canRetryWrite() {
|
||||
if (super.canRetryWrite === false) {
|
||||
return false;
|
||||
}
|
||||
return this.statements.every(op => op.multi == null || op.multi === false);
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const options = this.options ?? {};
|
||||
const ordered = typeof options.ordered === 'boolean' ? options.ordered : true;
|
||||
const command = {
|
||||
update: this.ns.collection,
|
||||
updates: this.statements,
|
||||
ordered
|
||||
};
|
||||
if (typeof options.bypassDocumentValidation === 'boolean') {
|
||||
command.bypassDocumentValidation = options.bypassDocumentValidation;
|
||||
}
|
||||
if (options.let) {
|
||||
command.let = options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
|
||||
if (unacknowledgedWrite) {
|
||||
if (this.statements.find((o) => o.hint)) {
|
||||
// TODO(NODE-3541): fix error for hint with unacknowledged writes
|
||||
callback(new error_1.MongoCompatibilityError(`hint is not supported with unacknowledged writes`));
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.executeCommand(server, session, command, callback);
|
||||
}
|
||||
}
|
||||
exports.UpdateOperation = UpdateOperation;
|
||||
/** @internal */
|
||||
class UpdateOneOperation extends UpdateOperation {
|
||||
constructor(collection, filter, update, options) {
|
||||
super(collection.s.namespace, [makeUpdateStatement(filter, update, { ...options, multi: false })], options);
|
||||
if (!(0, utils_1.hasAtomicOperators)(update)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Update document requires atomic operators');
|
||||
}
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, (err, res) => {
|
||||
if (err || !res)
|
||||
return callback(err);
|
||||
if (this.explain != null)
|
||||
return callback(undefined, res);
|
||||
if (res.code)
|
||||
return callback(new error_1.MongoServerError(res));
|
||||
if (res.writeErrors)
|
||||
return callback(new error_1.MongoServerError(res.writeErrors[0]));
|
||||
callback(undefined, {
|
||||
acknowledged: this.writeConcern?.w !== 0 ?? true,
|
||||
modifiedCount: res.nModified != null ? res.nModified : res.n,
|
||||
upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
|
||||
upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
|
||||
matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.UpdateOneOperation = UpdateOneOperation;
|
||||
/** @internal */
|
||||
class UpdateManyOperation extends UpdateOperation {
|
||||
constructor(collection, filter, update, options) {
|
||||
super(collection.s.namespace, [makeUpdateStatement(filter, update, { ...options, multi: true })], options);
|
||||
if (!(0, utils_1.hasAtomicOperators)(update)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Update document requires atomic operators');
|
||||
}
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, (err, res) => {
|
||||
if (err || !res)
|
||||
return callback(err);
|
||||
if (this.explain != null)
|
||||
return callback(undefined, res);
|
||||
if (res.code)
|
||||
return callback(new error_1.MongoServerError(res));
|
||||
if (res.writeErrors)
|
||||
return callback(new error_1.MongoServerError(res.writeErrors[0]));
|
||||
callback(undefined, {
|
||||
acknowledged: this.writeConcern?.w !== 0 ?? true,
|
||||
modifiedCount: res.nModified != null ? res.nModified : res.n,
|
||||
upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
|
||||
upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
|
||||
matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.UpdateManyOperation = UpdateManyOperation;
|
||||
/** @internal */
|
||||
class ReplaceOneOperation extends UpdateOperation {
|
||||
constructor(collection, filter, replacement, options) {
|
||||
super(collection.s.namespace, [makeUpdateStatement(filter, replacement, { ...options, multi: false })], options);
|
||||
if ((0, utils_1.hasAtomicOperators)(replacement)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Replacement document must not contain atomic operators');
|
||||
}
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
super.execute(server, session, (err, res) => {
|
||||
if (err || !res)
|
||||
return callback(err);
|
||||
if (this.explain != null)
|
||||
return callback(undefined, res);
|
||||
if (res.code)
|
||||
return callback(new error_1.MongoServerError(res));
|
||||
if (res.writeErrors)
|
||||
return callback(new error_1.MongoServerError(res.writeErrors[0]));
|
||||
callback(undefined, {
|
||||
acknowledged: this.writeConcern?.w !== 0 ?? true,
|
||||
modifiedCount: res.nModified != null ? res.nModified : res.n,
|
||||
upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
|
||||
upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
|
||||
matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ReplaceOneOperation = ReplaceOneOperation;
|
||||
function makeUpdateStatement(filter, update, options) {
|
||||
if (filter == null || typeof filter !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Selector must be a valid JavaScript object');
|
||||
}
|
||||
if (update == null || typeof update !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Document must be a valid JavaScript object');
|
||||
}
|
||||
const op = { q: filter, u: update };
|
||||
if (typeof options.upsert === 'boolean') {
|
||||
op.upsert = options.upsert;
|
||||
}
|
||||
if (options.multi) {
|
||||
op.multi = options.multi;
|
||||
}
|
||||
if (options.hint) {
|
||||
op.hint = options.hint;
|
||||
}
|
||||
if (options.arrayFilters) {
|
||||
op.arrayFilters = options.arrayFilters;
|
||||
}
|
||||
if (options.collation) {
|
||||
op.collation = options.collation;
|
||||
}
|
||||
return op;
|
||||
}
|
||||
exports.makeUpdateStatement = makeUpdateStatement;
|
||||
(0, operation_1.defineAspects)(UpdateOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION, operation_1.Aspect.SKIP_COLLATION]);
|
||||
(0, operation_1.defineAspects)(UpdateOneOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SKIP_COLLATION
|
||||
]);
|
||||
(0, operation_1.defineAspects)(UpdateManyOperation, [
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SKIP_COLLATION
|
||||
]);
|
||||
(0, operation_1.defineAspects)(ReplaceOneOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.SKIP_COLLATION
|
||||
]);
|
||||
//# sourceMappingURL=update.js.map
|
||||
1
node_modules/mongodb/lib/operations/update.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/update.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
41
node_modules/mongodb/lib/operations/validate_collection.js
generated
vendored
Normal file
41
node_modules/mongodb/lib/operations/validate_collection.js
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ValidateCollectionOperation = void 0;
|
||||
const error_1 = require("../error");
|
||||
const command_1 = require("./command");
|
||||
/** @internal */
|
||||
class ValidateCollectionOperation extends command_1.CommandOperation {
|
||||
constructor(admin, collectionName, options) {
|
||||
// Decorate command with extra options
|
||||
const command = { validate: collectionName };
|
||||
const keys = Object.keys(options);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (Object.prototype.hasOwnProperty.call(options, keys[i]) && keys[i] !== 'session') {
|
||||
command[keys[i]] = options[keys[i]];
|
||||
}
|
||||
}
|
||||
super(admin.s.db, options);
|
||||
this.options = options;
|
||||
this.command = command;
|
||||
this.collectionName = collectionName;
|
||||
}
|
||||
execute(server, session, callback) {
|
||||
const collectionName = this.collectionName;
|
||||
super.executeCommand(server, session, this.command, (err, doc) => {
|
||||
if (err != null)
|
||||
return callback(err);
|
||||
// TODO(NODE-3483): Replace these with MongoUnexpectedServerResponseError
|
||||
if (doc.ok === 0)
|
||||
return callback(new error_1.MongoRuntimeError('Error with validate command'));
|
||||
if (doc.result != null && typeof doc.result !== 'string')
|
||||
return callback(new error_1.MongoRuntimeError('Error with validation data'));
|
||||
if (doc.result != null && doc.result.match(/exception|corrupt/) != null)
|
||||
return callback(new error_1.MongoRuntimeError(`Invalid collection ${collectionName}`));
|
||||
if (doc.valid != null && !doc.valid)
|
||||
return callback(new error_1.MongoRuntimeError(`Invalid collection ${collectionName}`));
|
||||
return callback(undefined, doc);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ValidateCollectionOperation = ValidateCollectionOperation;
|
||||
//# sourceMappingURL=validate_collection.js.map
|
||||
1
node_modules/mongodb/lib/operations/validate_collection.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/validate_collection.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"validate_collection.js","sourceRoot":"","sources":["../../src/operations/validate_collection.ts"],"names":[],"mappings":";;;AAEA,oCAA6C;AAI7C,uCAAsE;AAQtE,gBAAgB;AAChB,MAAa,2BAA4B,SAAQ,0BAA0B;IAKzE,YAAY,KAAY,EAAE,cAAsB,EAAE,OAAkC;QAClF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