flow like the river

This commit is contained in:
root 2025-11-07 00:06:12 +01:00
commit 013fe673f3
42435 changed files with 5764238 additions and 0 deletions

97
BACK_BACK/node_modules/mongodb/lib/operations/aggregate.js generated vendored Executable file
View file

@ -0,0 +1,97 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AggregateOperation = exports.DB_AGGREGATE_COLLECTION = void 0;
const responses_1 = require("../cmap/wire_protocol/responses");
const error_1 = require("../error");
const utils_1 = require("../utils");
const write_concern_1 = require("../write_concern");
const command_1 = require("./command");
const operation_1 = require("./operation");
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
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 commandName() {
return 'aggregate';
}
get canRetryRead() {
return !this.hasWriteStage;
}
addToPipeline(stage) {
this.pipeline.push(stage);
}
async execute(server, session) {
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) {
write_concern_1.WriteConcern.apply(command, 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;
}
return await super.executeCommand(server, session, command, this.explain ? responses_1.ExplainedCursorResponse : responses_1.CursorResponse);
}
}
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

View file

@ -0,0 +1 @@
{"version":3,"file":"aggregate.js","sourceRoot":"","sources":["../../src/operations/aggregate.ts"],"names":[],"mappings":";;;AACA,+DAA0F;AAC1F,oCAAqD;AAGrD,oCAAiE;AACjE,oDAAgD;AAChD,uCAAkG;AAClG,2CAA+D;AAE/D,gBAAgB;AAChB,4EAA4E;AAC/D,QAAA,uBAAuB,GAAG,CAAU,CAAC;AAClD,MAAM,0CAA0C,GAAG,CAAC,CAAC;AA0BrD,gBAAgB;AAChB,MAAa,kBAAmB,SAAQ,0BAAgC;IAMtE,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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C;QAED,iEAAiE;QACjE,gDAAgD;QAChD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAClC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACpC,CAAC;QAED,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YAC7C,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QAC/C,CAAC;QAED,OAAO,MAAM,KAAK,CAAC,cAAc,CAC/B,MAAM,EACN,OAAO,EACP,OAAO,EACP,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,mCAAuB,CAAC,CAAC,CAAC,0BAAc,CACxD,CAAC;IACJ,CAAC;CACF;AA3GD,gDA2GC;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"}

34
BACK_BACK/node_modules/mongodb/lib/operations/bulk_write.js generated vendored Executable file
View file

@ -0,0 +1,34 @@
"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;
}
get commandName() {
return 'bulkWrite';
}
async execute(server, session) {
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
for (let i = 0; i < operations.length; i++) {
bulk.raw(operations[i]);
}
// Execute the bulk
return await bulk.execute({ ...options, session });
}
}
exports.BulkWriteOperation = BulkWriteOperation;
(0, operation_1.defineAspects)(BulkWriteOperation, [operation_1.Aspect.WRITE_OPERATION]);
//# sourceMappingURL=bulk_write.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"bulk_write.js","sourceRoot":"","sources":["../../src/operations/bulk_write.ts"],"names":[],"mappings":";;;AASA,2CAAuE;AAEvE,gBAAgB;AAChB,MAAa,kBAAmB,SAAQ,6BAAkC;IAKxE,YACE,UAAsB,EACtB,UAAgD,EAChD,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;IAED,IAAa,WAAW;QACtB,OAAO,WAAoB,CAAC;IAC9B,CAAC;IAEQ,KAAK,CAAC,OAAO,CACpB,MAAc,EACd,OAAkC;QAElC,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,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;QAED,mBAAmB;QACnB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;CACF;AA1CD,gDA0CC;AAED,IAAA,yBAAa,EAAC,kBAAkB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}

View file

@ -0,0 +1,198 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildReplaceOneOperation = exports.buildUpdateManyOperation = exports.buildUpdateOneOperation = exports.buildDeleteManyOperation = exports.buildDeleteOneOperation = exports.buildInsertOneOperation = exports.ClientBulkWriteCommandBuilder = void 0;
exports.buildOperation = buildOperation;
const commands_1 = require("../../cmap/commands");
/** @internal */
class ClientBulkWriteCommandBuilder {
/**
* Create the command builder.
* @param models - The client write models.
*/
constructor(models, options) {
this.models = models;
this.options = options;
}
/**
* Gets the errorsOnly value for the command, which is the inverse of the
* user provided verboseResults option. Defaults to true.
*/
get errorsOnly() {
if ('verboseResults' in this.options) {
return !this.options.verboseResults;
}
return true;
}
/**
* Build the bulk write commands from the models.
*/
buildCommands() {
// Iterate the models to build the ops and nsInfo fields.
const operations = [];
let currentNamespaceIndex = 0;
const namespaces = new Map();
for (const model of this.models) {
const ns = model.namespace;
const index = namespaces.get(ns);
if (index != null) {
operations.push(buildOperation(model, index));
}
else {
namespaces.set(ns, currentNamespaceIndex);
operations.push(buildOperation(model, currentNamespaceIndex));
currentNamespaceIndex++;
}
}
const nsInfo = Array.from(namespaces.keys(), ns => ({ ns }));
// The base command.
const command = {
bulkWrite: 1,
errorsOnly: this.errorsOnly,
ordered: this.options.ordered ?? true,
ops: new commands_1.DocumentSequence(operations),
nsInfo: new commands_1.DocumentSequence(nsInfo)
};
// Add bypassDocumentValidation if it was present in the options.
if (this.options.bypassDocumentValidation != null) {
command.bypassDocumentValidation = this.options.bypassDocumentValidation;
}
// Add let if it was present in the options.
if (this.options.let) {
command.let = this.options.let;
}
return [command];
}
}
exports.ClientBulkWriteCommandBuilder = ClientBulkWriteCommandBuilder;
/**
* Build the insert one operation.
* @param model - The insert one model.
* @param index - The namespace index.
* @returns the operation.
*/
const buildInsertOneOperation = (model, index) => {
const document = {
insert: index,
document: model.document
};
return document;
};
exports.buildInsertOneOperation = buildInsertOneOperation;
/**
* Build the delete one operation.
* @param model - The insert many model.
* @param index - The namespace index.
* @returns the operation.
*/
const buildDeleteOneOperation = (model, index) => {
return createDeleteOperation(model, index, false);
};
exports.buildDeleteOneOperation = buildDeleteOneOperation;
/**
* Build the delete many operation.
* @param model - The delete many model.
* @param index - The namespace index.
* @returns the operation.
*/
const buildDeleteManyOperation = (model, index) => {
return createDeleteOperation(model, index, true);
};
exports.buildDeleteManyOperation = buildDeleteManyOperation;
/**
* Creates a delete operation based on the parameters.
*/
function createDeleteOperation(model, index, multi) {
const document = {
delete: index,
multi: multi,
filter: model.filter
};
if (model.hint) {
document.hint = model.hint;
}
if (model.collation) {
document.collation = model.collation;
}
return document;
}
/**
* Build the update one operation.
* @param model - The update one model.
* @param index - The namespace index.
* @returns the operation.
*/
const buildUpdateOneOperation = (model, index) => {
return createUpdateOperation(model, index, false);
};
exports.buildUpdateOneOperation = buildUpdateOneOperation;
/**
* Build the update many operation.
* @param model - The update many model.
* @param index - The namespace index.
* @returns the operation.
*/
const buildUpdateManyOperation = (model, index) => {
return createUpdateOperation(model, index, true);
};
exports.buildUpdateManyOperation = buildUpdateManyOperation;
/**
* Creates a delete operation based on the parameters.
*/
function createUpdateOperation(model, index, multi) {
const document = {
update: index,
multi: multi,
filter: model.filter,
updateMods: model.update
};
if (model.hint) {
document.hint = model.hint;
}
if (model.upsert) {
document.upsert = model.upsert;
}
if (model.arrayFilters) {
document.arrayFilters = model.arrayFilters;
}
return document;
}
/**
* Build the replace one operation.
* @param model - The replace one model.
* @param index - The namespace index.
* @returns the operation.
*/
const buildReplaceOneOperation = (model, index) => {
const document = {
update: index,
multi: false,
filter: model.filter,
updateMods: model.replacement
};
if (model.hint) {
document.hint = model.hint;
}
if (model.upsert) {
document.upsert = model.upsert;
}
return document;
};
exports.buildReplaceOneOperation = buildReplaceOneOperation;
/** @internal */
function buildOperation(model, index) {
switch (model.name) {
case 'insertOne':
return (0, exports.buildInsertOneOperation)(model, index);
case 'deleteOne':
return (0, exports.buildDeleteOneOperation)(model, index);
case 'deleteMany':
return (0, exports.buildDeleteManyOperation)(model, index);
case 'updateOne':
return (0, exports.buildUpdateOneOperation)(model, index);
case 'updateMany':
return (0, exports.buildUpdateManyOperation)(model, index);
case 'replaceOne':
return (0, exports.buildReplaceOneOperation)(model, index);
}
}
//# sourceMappingURL=command_builder.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"command_builder.js","sourceRoot":"","sources":["../../../src/operations/client_bulk_write/command_builder.ts"],"names":[],"mappings":";;;AA2QA,wCAeC;AAzRD,kDAAuD;AA0BvD,gBAAgB;AAChB,MAAa,6BAA6B;IAIxC;;;OAGG;IACH,YAAY,MAAiC,EAAE,OAA+B;QAC5E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,IAAI,UAAU;QACZ,IAAI,gBAAgB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QACtC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,aAAa;QACX,yDAAyD;QACzD,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,qBAAqB,GAAG,CAAC,CAAC;QAC9B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC7C,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;YAC3B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC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CAAC;AAjBW,QAAA,wBAAwB,4BAiBnC;AAEF,gBAAgB;AAChB,SAAgB,cAAc,CAAC,KAA8B,EAAE,KAAa;IAC1E,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,WAAW;YACd,OAAO,IAAA,+BAAuB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/C,KAAK,WAAW;YACd,OAAO,IAAA,+BAAuB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/C,KAAK,YAAY;YACf,OAAO,IAAA,gCAAwB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAChD,KAAK,WAAW;YACd,OAAO,IAAA,+BAAuB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/C,KAAK,YAAY;YACf,OAAO,IAAA,gCAAwB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAChD,KAAK,YAAY;YACf,OAAO,IAAA,gCAAwB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}

View file

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=common.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/operations/client_bulk_write/common.ts"],"names":[],"mappings":""}

33
BACK_BACK/node_modules/mongodb/lib/operations/collections.js generated vendored Executable file
View file

@ -0,0 +1,33 @@
"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;
}
get commandName() {
return 'listCollections';
}
async execute(server, session) {
// Let's get the collection names
const documents = await this.db
.listCollections({}, { ...this.options, nameOnly: true, readPreference: this.readPreference, session })
.toArray();
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
return collections;
}
}
exports.CollectionsOperation = CollectionsOperation;
//# sourceMappingURL=collections.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/operations/collections.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAI3C,2CAAuE;AAMvE,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;IAED,IAAa,WAAW;QACtB,OAAO,iBAA0B,CAAC;IACpC,CAAC;IAEQ,KAAK,CAAC,OAAO,CACpB,MAAc,EACd,OAAkC;QAElC,iCAAiC;QACjC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,EAAE;aAC5B,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,CAAC;QACb,MAAM,WAAW,GAAiB,EAAE,CAAC;QACrC,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxB,+CAA+C;gBAC/C,WAAW,CAAC,IAAI,CAAC,IAAI,uBAAU,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;QACD,gCAAgC;QAChC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAnCD,oDAmCC"}

77
BACK_BACK/node_modules/mongodb/lib/operations/command.js generated vendored Executable file
View file

@ -0,0 +1,77 @@
"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 super.canRetryWrite;
}
async executeCommand(server, session, cmd, responseType) {
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) {
write_concern_1.WriteConcern.apply(cmd, 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);
}
return await server.command(this.ns, cmd, options, responseType);
}
}
exports.CommandOperation = CommandOperation;
//# sourceMappingURL=command.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/operations/command.ts"],"names":[],"mappings":";;;AAEA,oCAAqD;AACrD,wCAA0D;AAC1D,kDAA8C;AAG9C,+DAA4E;AAE5E,oCAKkB;AAClB,oDAA0E;AAE1E,2CAA+E;AAoD/E,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;QAE7B,kFAAkF;QAClF,kFAAkF;QAClF,qBAAqB;QACrB,MAAM,cAAc,GAAG,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,CAAC;QAC1D,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,EAAE,GAAG,IAAI,wBAAgB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,EAAE,GAAG,MAAM;gBACd,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC3C,CAAC,CAAC,IAAI,wBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,0BAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,YAAY,GAAG,4BAAY,CAAC,WA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AAkB,GAAG,IAAI,CAAC;QACpC,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,CAAC,kBAAM,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YAClF,4BAAY,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7C,CAAC;QAED,IACE,OAAO,CAAC,SAAS;YACjB,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ;YACrC,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAM,CAAC,cAAc,CAAC,EACtC,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC1C,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,CAAC,kBAAM,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvD,GAAG,GAAG,IAAA,2BAAmB,EAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IACnE,CAAC;CACF;AApGD,4CAoGC"}

41
BACK_BACK/node_modules/mongodb/lib/operations/count.js generated vendored Executable file
View file

@ -0,0 +1,41 @@
"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;
}
get commandName() {
return 'count';
}
async execute(server, session) {
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;
}
const result = await super.executeCommand(server, session, cmd);
return 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
BACK_BACK/node_modules/mongodb/lib/operations/count.js.map generated vendored Executable file
View file

@ -0,0 +1 @@
{"version":3,"file":"count.js","sourceRoot":"","sources":["../../src/operations/count.ts"],"names":[],"mappings":";;;AAKA,uCAA2E;AAC3E,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;IAED,IAAa,WAAW;QACtB,OAAO,OAAgB,CAAC;IAC1B,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,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,CAAC;YACtC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC1C,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAChE,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;CACF;AA3CD,wCA2CC;AAED,IAAA,yBAAa,EAAC,cAAc,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,SAAS,CAAC,CAAC,CAAC"}

View file

@ -0,0 +1,102 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateCollectionOperation = void 0;
const constants_1 = require("../cmap/wire_protocol/constants");
const collection_1 = require("../collection");
const error_1 = require("../error");
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 */
const INVALID_QE_VERSION = 'Driver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption.';
/** @internal */
class CreateCollectionOperation extends command_1.CommandOperation {
constructor(db, name, options = {}) {
super(db, options);
this.options = options;
this.db = db;
this.name = name;
}
get commandName() {
return 'create';
}
async execute(server, session) {
const db = this.db;
const name = this.name;
const options = this.options;
const encryptedFields = options.encryptedFields ??
db.client.options.autoEncryption?.encryptedFieldsMap?.[`${db.databaseName}.${name}`];
if (encryptedFields) {
// Creating a QE collection required min server of 7.0.0
// TODO(NODE-5353): Get wire version information from connection.
if (!server.loadBalanced &&
server.description.maxWireVersion < constants_1.MIN_SUPPORTED_QE_WIRE_VERSION) {
throw new error_1.MongoCompatibilityError(`${INVALID_QE_VERSION} The minimum server version required is ${constants_1.MIN_SUPPORTED_QE_SERVER_VERSION}`);
}
// Create auxilliary collections for queryable encryption support.
const escCollection = encryptedFields.escCollection ?? `enxcol_.${name}.esc`;
const ecocCollection = encryptedFields.ecocCollection ?? `enxcol_.${name}.ecoc`;
for (const collectionName of [escCollection, 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 = indexes_1.CreateIndexesOperation.fromIndexSpecification(db, name, { __safeContent__: 1 }, {});
await createIndexOp.execute(server, session);
}
return coll;
}
async executeWithoutEncryptedFieldsCheck(server, session) {
const db = this.db;
const name = this.name;
const options = this.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
await super.executeCommand(server, session, cmd);
return new collection_1.Collection(db, name, options);
}
}
exports.CreateCollectionOperation = CreateCollectionOperation;
(0, operation_1.defineAspects)(CreateCollectionOperation, [operation_1.Aspect.WRITE_OPERATION]);
//# sourceMappingURL=create_collection.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"create_collection.js","sourceRoot":"","sources":["../../src/operations/create_collection.ts"],"names":[],"mappings":";;;AACA,+DAGyC;AACzC,8CAA2C;AAE3C,oCAAmD;AAInD,uCAA2E;AAC3E,uCAAmD;AACnD,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,eAAe;AACf,MAAM,kBAAkB,GACtB,iHAAiH,CAAC;AAEpH,gBAAgB;AAChB,MAAa,yBAA0B,SAAQ,0BAA4B;IAKzE,YAAY,EAAM,EAAE,IAAY,EAAE,UAAmC,EAAE;QACrE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,QAAiB,CAAC;IAC3B,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7B,MAAM,eAAe,GACnB,OAAO,CAAC,eAAe;YACvB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,kBAAkB,EAAE,CA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ACF,MAAM,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,KAAK,CAAC,kCAAkC,CAC9C,MAAc,EACd,OAAkC;QAElC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7B,MAAM,GAAG,GAAa,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACvC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,IACG,OAAe,CAAC,CAAC,CAAC,IAAI,IAAI;gBAC3B,OAAQ,OAAe,CAAC,CAAC,CAAC,KAAK,UAAU;gBACzC,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAC9B,CAAC;gBACD,GAAG,CAAC,CAAC,CAAC,GAAI,OAAe,CAAC,CAAC,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,qCAAqC;QACrC,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QACjD,OAAO,IAAI,uBAAU,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;CACF;AA9FD,8DA8FC;AAED,IAAA,yBAAa,EAAC,yBAAyB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}

116
BACK_BACK/node_modules/mongodb/lib/operations/delete.js generated vendored Executable file
View file

@ -0,0 +1,116 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteManyOperation = exports.DeleteOneOperation = exports.DeleteOperation = void 0;
exports.makeDeleteStatement = makeDeleteStatement;
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 commandName() {
return 'delete';
}
get canRetryWrite() {
if (super.canRetryWrite === false) {
return false;
}
return this.statements.every(op => (op.limit != null ? op.limit > 0 : true));
}
async execute(server, session) {
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
throw new error_1.MongoCompatibilityError(`hint is not supported with unacknowledged writes`);
}
}
const res = await super.executeCommand(server, session, command);
return res;
}
}
exports.DeleteOperation = DeleteOperation;
class DeleteOneOperation extends DeleteOperation {
constructor(collection, filter, options) {
super(collection.s.namespace, [makeDeleteStatement(filter, { ...options, limit: 1 })], options);
}
async execute(server, session) {
const res = await super.execute(server, session);
if (this.explain)
return res;
if (res.code)
throw new error_1.MongoServerError(res);
if (res.writeErrors)
throw new error_1.MongoServerError(res.writeErrors[0]);
return {
acknowledged: this.writeConcern?.w !== 0,
deletedCount: res.n
};
}
}
exports.DeleteOneOperation = DeleteOneOperation;
class DeleteManyOperation extends DeleteOperation {
constructor(collection, filter, options) {
super(collection.s.namespace, [makeDeleteStatement(filter, options)], options);
}
async execute(server, session) {
const res = await super.execute(server, session);
if (this.explain)
return res;
if (res.code)
throw new error_1.MongoServerError(res);
if (res.writeErrors)
throw new error_1.MongoServerError(res.writeErrors[0]);
return {
acknowledged: this.writeConcern?.w !== 0,
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;
}
(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

View file

@ -0,0 +1 @@
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/operations/delete.ts"],"names":[],"mappings":";;;AA+IA,kDAkBC;AA/JD,oCAAqE;AAMrE,uCAAkG;AAClG,2CAA+D;AAkC/D,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,0BAA8B;IAIjE,YAAY,EAAoB,EAAE,UAA6B,EAAE,OAAsB;QACrF,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,QAAiB,CAAC;IAC3B,CAAC;IAED,IAAa,aAAa;QACxB,IAAI,KAAK,CAAC,aAAa,KAAK,KAAK,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/E,CAAC;IAEQ,KAAK,CAAC,OAAO,CACpB,MAAc,EACd,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AAC,CAAC;QAEpE,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;YACxC,YAAY,EAAE,GAAG,CAAC,CAAC;SACpB,CAAC;IACJ,CAAC;CACF;AAnBD,kDAmBC;AAED,SAAgB,mBAAmB,CACjC,MAAgB,EAChB,OAA2C;IAE3C,MAAM,EAAE,GAAoB;QAC1B,CAAC,EAAE,MAAM;QACT,KAAK,EAAE,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC7D,CAAC;IAEF,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,EAAE,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACnC,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,EAAE,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;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"}

60
BACK_BACK/node_modules/mongodb/lib/operations/distinct.js generated vendored Executable file
View file

@ -0,0 +1,60 @@
"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;
}
get commandName() {
return 'distinct';
}
async execute(server, session) {
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
(0, utils_1.decorateWithCollation)(cmd, coll, options);
const result = await super.executeCommand(server, session, cmd);
return 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

View file

@ -0,0 +1 @@
{"version":3,"file":"distinct.js","sourceRoot":"","sources":["../../src/operations/distinct.ts"],"names":[],"mappings":";;;AAIA,oCAA0E;AAC1E,uCAA2E;AAC3E,2CAAoD;AAKpD;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,0BAAuB;IAQ5D;;;;;;;OAOG;IACH,YAAY,UAAsB,EAAE,GAAW,EAAE,KAAe,EAAE,OAAyB;QACzF,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAE3B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QA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AA,yBAAa,EAAC,iBAAiB,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,SAAS,EAAE,kBAAM,CAAC,WAAW,CAAC,CAAC,CAAC"}

76
BACK_BACK/node_modules/mongodb/lib/operations/drop.js generated vendored Executable file
View file

@ -0,0 +1,76 @@
"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;
}
get commandName() {
return 'drop';
}
async execute(server, session) {
const db = this.db;
const options = this.options;
const name = this.name;
const encryptedFieldsMap = db.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 ecocCollection = encryptedFields.ecocCollection || `enxcol_.${name}.ecoc`;
for (const collectionName of [escCollection, 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 await this.executeWithoutEncryptedFieldsCheck(server, session);
}
async executeWithoutEncryptedFieldsCheck(server, session) {
await super.executeCommand(server, session, { drop: this.name });
return true;
}
}
exports.DropCollectionOperation = DropCollectionOperation;
/** @internal */
class DropDatabaseOperation extends command_1.CommandOperation {
constructor(db, options) {
super(db, options);
this.options = options;
}
get commandName() {
return 'dropDatabase';
}
async execute(server, session) {
await super.executeCommand(server, session, { dropDatabase: 1 });
return true;
}
}
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
BACK_BACK/node_modules/mongodb/lib/operations/drop.js.map generated vendored Executable file
View file

@ -0,0 +1 @@
{"version":3,"file":"drop.js","sourceRoot":"","sources":["../../src/operations/drop.ts"],"names":[],"mappings":";;;AAEA,oCAAiE;AAGjE,uCAA2E;AAC3E,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;IAED,IAAa,WAAW;QACtB,OAAO,MAAe,CAAC;IACzB,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,MAAM,kBAAkB,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,kBAAkB,CAAC;QAChF,IAAI,eAAe,GACjB,OAAO,CAAC,eAAe,IAAI,kBAAkB,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,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AAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlED,0DAkEC;AAKD,gBAAgB;AAChB,MAAa,qBAAsB,SAAQ,0BAAyB;IAGlE,YAAY,EAAM,EAAE,OAA4B;QAC9C,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD,IAAa,WAAW;QACtB,OAAO,cAAuB,CAAC;IACjC,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAfD,sDAeC;AAED,IAAA,yBAAa,EAAC,uBAAuB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AACjE,IAAA,yBAAa,EAAC,qBAAqB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}

View file

@ -0,0 +1,36 @@
"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;
}
get commandName() {
return 'count';
}
async execute(server, session) {
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;
}
const response = await super.executeCommand(server, session, cmd);
return 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

View file

@ -0,0 +1 @@
{"version":3,"file":"estimated_document_count.js","sourceRoot":"","sources":["../../src/operations/estimated_document_count.ts"],"names":[],"mappings":";;;AAIA,uCAA2E;AAC3E,2CAAoD;AAYpD,gBAAgB;AAChB,MAAa,+BAAgC,SAAQ,0BAAwB;IAI3E,YAAY,UAAsB,EAAE,UAAyC,EAAE;QAC7E,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;IAClD,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,OAAgB,CAAC;IAC1B,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,GAAG,GAAa,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;QAErD,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC/C,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QACzC,CAAC;QAED,iEAAiE;QACjE,gDAAgD;QAChD,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACvC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrC,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAElE,OAAO,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AA/BD,0EA+BC;AAED,IAAA,yBAAa,EAAC,+BAA+B,EAAE;IAC7C,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;CACvB,CAAC,CAAC"}

View file

@ -0,0 +1,208 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeOperation = executeOperation;
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.';
/**
* Executes the given operation with provided arguments.
* @internal
*
* @remarks
* Allows for a single point of entry to provide features such as implicit sessions, which
* are required by the Driver Sessions specification in the event that a ClientSession is
* not provided.
*
* The expectation is that this function:
* - Connects the MongoClient if it has not already been connected, see {@link autoConnect}
* - Creates a session if none is provided and cleans up the session it creates
* - Tries an operation and retries under certain conditions, see {@link tryOperation}
*
* @typeParam T - The operation's type
* @typeParam TResult - The type of the operation's result, calculated from T
*
* @param client - The MongoClient to execute this operation with
* @param operation - The operation to execute
*/
async function executeOperation(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');
}
const topology = await autoConnect(client);
// 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 (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 if (session.client !== client) {
throw new error_1.MongoInvalidArgumentError('ClientSession must be from the same MongoClient');
}
if (session.explicit && session?.timeoutMS != null && operation.options.timeoutMS != null) {
throw new error_1.MongoInvalidArgumentError('Do not specify timeoutMS on operation if already specified on an explicit session');
}
const readPreference = operation.readPreference ?? read_preference_1.ReadPreference.primary;
const inTransaction = !!session?.inTransaction();
const hasReadAspect = operation.hasAspect(operation_1.Aspect.READ_OPERATION);
if (inTransaction &&
!readPreference.equals(read_preference_1.ReadPreference.primary) &&
(hasReadAspect || operation.commandName === 'runCommand')) {
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();
}
try {
return await tryOperation(operation, {
topology,
session,
readPreference
});
}
finally {
if (session?.owner != null && session.owner === owner) {
await session.endSession();
}
}
}
/**
* Connects a client if it has not yet been connected
* @internal
*/
async function autoConnect(client) {
if (client.topology == null) {
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();
if (client.topology == null) {
throw new error_1.MongoRuntimeError('client.connect did not create a topology but also did not throw');
}
return client.topology;
}
finally {
delete client.s.options[Symbol.for('@@mdb.skipPingOnConnect')];
}
}
return client.topology;
}
/**
* Executes an operation and retries as appropriate
* @internal
*
* @remarks
* Implements behaviour described in [Retryable Reads](https://github.com/mongodb/specifications/blob/master/source/retryable-reads/retryable-reads.md) and [Retryable
* Writes](https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.md) specification
*
* This function:
* - performs initial server selection
* - attempts to execute an operation
* - retries the operation if it meets the criteria for a retryable read or a retryable write
*
* @typeParam T - The operation's type
* @typeParam TResult - The type of the operation's result, calculated from T
*
* @param operation - The operation to execute
* */
async function tryOperation(operation, { topology, session, readPreference }) {
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;
}
let server = await topology.selectServer(selector, {
session,
operationName: operation.commandName
});
const hasReadAspect = operation.hasAspect(operation_1.Aspect.READ_OPERATION);
const hasWriteAspect = operation.hasAspect(operation_1.Aspect.WRITE_OPERATION);
const inTransaction = session?.inTransaction() ?? false;
const willRetryRead = topology.s.options.retryReads && !inTransaction && operation.canRetryRead;
const willRetryWrite = topology.s.options.retryWrites &&
!inTransaction &&
(0, utils_1.supportsRetryableWrites)(server) &&
operation.canRetryWrite;
const willRetry = operation.hasAspect(operation_1.Aspect.RETRYABLE) &&
session != null &&
((hasReadAspect && willRetryRead) || (hasWriteAspect && willRetryWrite));
if (hasWriteAspect && willRetryWrite && session != null) {
operation.options.willRetryWrite = true;
session.incrementTransactionNumber();
}
// TODO(NODE-6231): implement infinite retry within CSOT timeout here
const maxTries = willRetry ? 2 : 1;
let previousOperationError;
let previousServer;
// TODO(NODE-6231): implement infinite retry within CSOT timeout here
for (let tries = 0; tries < maxTries; tries++) {
if (previousOperationError) {
if (hasWriteAspect && previousOperationError.code === MMAPv1_RETRY_WRITES_ERROR_CODE) {
throw new error_1.MongoServerError({
message: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
errmsg: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
originalError: previousOperationError
});
}
if (hasWriteAspect && !(0, error_1.isRetryableWriteError)(previousOperationError))
throw previousOperationError;
if (hasReadAspect && !(0, error_1.isRetryableReadError)(previousOperationError))
throw previousOperationError;
if (previousOperationError instanceof error_1.MongoNetworkError &&
operation.hasAspect(operation_1.Aspect.CURSOR_CREATING) &&
session != null &&
session.isPinned &&
!session.inTransaction()) {
session.unpin({ force: true, forceClear: true });
}
server = await topology.selectServer(selector, {
session,
operationName: operation.commandName,
previousServer
});
if (hasWriteAspect && !(0, utils_1.supportsRetryableWrites)(server)) {
throw new error_1.MongoUnexpectedServerResponseError('Selected server does not support retryable writes');
}
}
try {
return await operation.execute(server, session);
}
catch (operationError) {
if (!(operationError instanceof error_1.MongoError))
throw operationError;
if (previousOperationError != null &&
operationError.hasErrorLabel(error_1.MongoErrorLabel.NoWritesPerformed)) {
throw previousOperationError;
}
previousServer = server.description;
previousOperationError = operationError;
}
}
throw (previousOperationError ??
new error_1.MongoRuntimeError('Tried to propagate retryability error, but no error was found.'));
}
//# sourceMappingURL=execute_operation.js.map

File diff suppressed because one or more lines are too long

153
BACK_BACK/node_modules/mongodb/lib/operations/find.js generated vendored Executable file
View file

@ -0,0 +1,153 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FindOperation = void 0;
const responses_1 = require("../cmap/wire_protocol/responses");
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(ns, filter = {}, options = {}) {
super(undefined, 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');
}
// special case passing in an ObjectId as a filter
this.filter = filter != null && filter._bsontype === 'ObjectId' ? { _id: filter } : filter;
}
get commandName() {
return 'find';
}
async execute(server, session) {
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);
}
return await server.command(this.ns, findCommand, {
...this.options,
...this.bsonOptions,
documentsReturnedIn: 'firstBatch',
session
}, this.explain ? responses_1.ExplainedCursorResponse : responses_1.CursorResponse);
}
}
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
BACK_BACK/node_modules/mongodb/lib/operations/find.js.map generated vendored Executable file
View file

@ -0,0 +1 @@
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/operations/find.ts"],"names":[],"mappings":";;;AACA,+DAA0F;AAC1F,oCAAqD;AACrD,kDAA8C;AAG9C,kCAAgD;AAChD,oCAA0F;AAC1F,uCAAkG;AAClG,2CAA+D;AA0D/D,gBAAgB;AAChB,MAAa,aAAc,SAAQ,0BAAgC;IAWjE,YAAY,EAAoB,EAAE,SAAmB,EAAE,EAAE,UAAuB,EAAE;QAChF,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE1B,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,CAAC;YACxD,MAAM,IAAI,iCAAyB,CAAC,iDAAiD,CAAC,CAAC;QACzF,CAAC;QAED,kDAAkD;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC7F,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,MAAe,CAAC;IACzB,CAAC;IAEQ,K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exports, "__esModule", { value: true });
exports.FindOneAndUpdateOperation = exports.FindOneAndReplaceOperation = exports.FindOneAndDeleteOperation = exports.FindAndModifyOperation = 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
};
options.includeResultMetadata ??= 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;
}
get commandName() {
return 'findAndModify';
}
async execute(server, session) {
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
};
(0, utils_1.decorateWithCollation)(cmd, coll, options);
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) {
throw new error_1.MongoCompatibilityError('The current topology does not support a hint on findAndModify commands');
}
cmd.hint = options.hint;
}
// Execute the command
const result = await super.executeCommand(server, session, cmd);
return options.includeResultMetadata ? result : (result.value ?? null);
}
}
exports.FindAndModifyOperation = FindAndModifyOperation;
/** @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

View 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,kCAAiE;AACjE,oCAAqF;AAErF,uCAA2E;AAC3E,2CAAoD;AAEpD,cAAc;AACD,QAAA,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACN,CAAC,CAAC;AA2FZ,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,CAAC;QAC9C,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IACtE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,0BAA0B;IAOpE,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,OAAO,CAAC,qBAAqB,KAAK,KAAK,CAAC;QAExC,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC,OAAO,CAAC,IAAI,C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,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;QAC7B,uCAAuC,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAE/D,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACnD,CAAC;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"}

62
BACK_BACK/node_modules/mongodb/lib/operations/get_more.js generated vendored Executable file
View file

@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetMoreOperation = void 0;
const responses_1 = require("../cmap/wire_protocol/responses");
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;
}
get commandName() {
return 'getMore';
}
/**
* 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.
*/
async execute(server, _session) {
if (server !== this.server) {
throw new error_1.MongoRuntimeError('Getmore must run on the same server operation began on');
}
if (this.cursorId == null || this.cursorId.isZero()) {
throw 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())
throw 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
};
return await server.command(this.ns, getMoreCmd, commandOptions, responses_1.CursorResponse);
}
}
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

View file

@ -0,0 +1 @@
{"version":3,"file":"get_more.js","sourceRoot":"","sources":["../../src/operations/get_more.ts"],"names":[],"mappings":";;;AACA,+DAAiE;AACjE,oCAA6C;AAG7C,oCAAiE;AACjE,2CAA8F;AA+B9F,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,IAAa,WAAW;QACtB,OAAO,SAAkB,CAAC;IAC5B,CAAC;IACD;;;OAGG;IACM,KAAK,CAAC,OAAO,CACpB,MAAc,EACd,QAAmC;QAEnC,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,IAAI,yBAAiB,CAAC,wDAAwD,CAAC,CAAC;QACxF,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YACp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,CAAC,uBAAuB,CAAC,CAAC,CAAC"}

176
BACK_BACK/node_modules/mongodb/lib/operations/indexes.js generated vendored Executable file
View file

@ -0,0 +1,176 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ListIndexesOperation = exports.DropIndexOperation = exports.CreateIndexesOperation = void 0;
const responses_1 = require("../cmap/wire_protocol/responses");
const error_1 = require("../error");
const utils_1 = require("../utils");
const command_1 = require("./command");
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]);
}
/**
* Converts an `IndexSpecification`, which can be specified in multiple formats, into a
* valid `key` for the createIndexes command.
*/
function constructIndexDescriptionMap(indexSpec) {
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 key;
}
/**
* Receives an index description and returns a modified index description which has had invalid options removed
* from the description and has mapped the `version` option to the `v` option.
*/
function resolveIndexDescription(description) {
const validProvidedOptions = Object.entries(description).filter(([optionName]) => VALID_INDEX_OPTIONS.has(optionName));
return Object.fromEntries(
// we support the `version` option, but the `createIndexes` command expects it to be the `v`
validProvidedOptions.map(([name, value]) => (name === 'version' ? ['v', value] : [name, value])));
}
/** @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 ?? Array.from(key).flat().join('_');
const validIndexOptions = resolveIndexDescription(userIndex);
return {
...validIndexOptions,
name,
key
};
});
}
static fromIndexDescriptionArray(parent, collectionName, indexes, options) {
return new CreateIndexesOperation(parent, collectionName, indexes, options);
}
static fromIndexSpecification(parent, collectionName, indexSpec, options = {}) {
const key = constructIndexDescriptionMap(indexSpec);
const description = { ...options, key };
return new CreateIndexesOperation(parent, collectionName, [description], options);
}
get commandName() {
return 'createIndexes';
}
async execute(server, session) {
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) {
throw new error_1.MongoCompatibilityError('Option `commitQuorum` for `createIndexes` not supported on servers < 4.4');
}
cmd.commitQuorum = options.commitQuorum;
}
// collation is set on each index, it should not be defined at the root
this.options.collation = undefined;
await super.executeCommand(server, session, cmd);
const indexNames = indexes.map(index => index.name || '');
return indexNames;
}
}
exports.CreateIndexesOperation = CreateIndexesOperation;
/** @internal */
class DropIndexOperation extends command_1.CommandOperation {
constructor(collection, indexName, options) {
super(collection, options);
this.options = options ?? {};
this.collection = collection;
this.indexName = indexName;
}
get commandName() {
return 'dropIndexes';
}
async execute(server, session) {
const cmd = { dropIndexes: this.collection.collectionName, index: this.indexName };
return await super.executeCommand(server, session, cmd);
}
}
exports.DropIndexOperation = DropIndexOperation;
/** @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;
}
get commandName() {
return 'listIndexes';
}
async execute(server, session) {
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;
}
return await super.executeCommand(server, session, command, responses_1.CursorResponse);
}
}
exports.ListIndexesOperation = ListIndexesOperation;
(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)(DropIndexOperation, [operation_1.Aspect.WRITE_OPERATION]);
//# sourceMappingURL=indexes.js.map

File diff suppressed because one or more lines are too long

101
BACK_BACK/node_modules/mongodb/lib/operations/insert.js generated vendored Executable file
View file

@ -0,0 +1,101 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InsertManyOperation = exports.InsertOneOperation = exports.InsertOperation = void 0;
const error_1 = require("../error");
const utils_1 = require("../utils");
const write_concern_1 = require("../write_concern");
const bulk_write_1 = require("./bulk_write");
const command_1 = require("./command");
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;
}
get commandName() {
return 'insert';
}
async execute(server, session) {
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;
}
return await super.executeCommand(server, session, command);
}
}
exports.InsertOperation = InsertOperation;
class InsertOneOperation extends InsertOperation {
constructor(collection, doc, options) {
super(collection.s.namespace, (0, utils_1.maybeAddIdToDocuments)(collection, [doc], options), options);
}
async execute(server, session) {
const res = await super.execute(server, session);
if (res.code)
throw new error_1.MongoServerError(res);
if (res.writeErrors) {
// This should be a WriteError but we can't change it now because of error hierarchy
throw new error_1.MongoServerError(res.writeErrors[0]);
}
return {
acknowledged: this.writeConcern?.w !== 0,
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;
}
get commandName() {
return 'insert';
}
async execute(server, session) {
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, this.docs.map(document => ({
insertOne: { document }
})), options);
try {
const res = await bulkWriteOperation.execute(server, session);
return {
acknowledged: writeConcern?.w !== 0,
insertedCount: res.insertedCount,
insertedIds: res.insertedIds
};
}
catch (err) {
if (err && err.message === 'Operation must be an object with an operation key') {
throw new error_1.MongoInvalidArgumentError('Collection.insertMany() cannot be called with an array that has null/undefined values');
}
throw err;
}
}
}
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]);
//# sourceM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AC,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
BACK_BACK/node_modules/mongodb/lib/operations/is_capped.js generated vendored Executable file
View 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;
}
get commandName() {
return 'listCollections';
}
async execute(server, session) {
const coll = this.collection;
const [collection] = await coll.s.db
.listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session })
.toArray();
if (collection == null || collection.options == null) {
throw new error_1.MongoAPIError(`collection ${coll.namespace} not found`);
}
return !!collection.options?.capped;
}
}
exports.IsCappedOperation = IsCappedOperation;
//# sourceMappingURL=is_capped.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"is_capped.js","sourceRoot":"","sources":["../../src/operations/is_capped.ts"],"names":[],"mappings":";;;AACA,oCAAyC;AAGzC,2CAAuE;AAEvE,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;IAED,IAAa,WAAW;QACtB,OAAO,iBAA0B,CAAC;IACpC,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAC7B,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE;aACjC,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,CAAC;QACb,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;YACrD,MAAM,IAAI,qBAAa,CAAC,cAAc,IAAI,CAAC,SAAS,YAAY,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC;IACtC,CAAC;CACF;AA3BD,8CA2BC"}

View file

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KillCursorsOperation = void 0;
const error_1 = require("../error");
const utils_1 = require("../utils");
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;
}
get commandName() {
return 'killCursors';
}
async execute(server, session) {
if (server !== this.server) {
throw 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())
throw new error_1.MongoRuntimeError('A collection name must be determined before killCursors');
}
const killCursorsCommand = {
killCursors,
cursors: [this.cursorId]
};
try {
await server.command(this.ns, killCursorsCommand, { session });
}
catch (error) {
// The driver should never emit errors from killCursors, this is spec-ed behavior
(0, utils_1.squashError)(error);
}
}
}
exports.KillCursorsOperation = KillCursorsOperation;
(0, operation_1.defineAspects)(KillCursorsOperation, [operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
//# sourceMappingURL=kill_cursors.js.map

View file

@ -0,0 +1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C,uBAAuB,CAAC,CAAC,CAAC"}

View file

@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ListCollectionsOperation = void 0;
const responses_1 = require("../cmap/wire_protocol/responses");
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;
}
}
get commandName() {
return 'listCollections';
}
async execute(server, session) {
return await super.executeCommand(server, session, this.generateCommand((0, utils_1.maxWireVersion)(server)), responses_1.CursorResponse);
}
/* 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

View file

@ -0,0 +1 @@
{"version":3,"file":"list_collections.js","sourceRoot":"","sources":["../../src/operations/list_collections.ts"],"names":[],"mappings":";;;AACA,+DAAiE;AAIjE,oCAA0C;AAC1C,uCAA2E;AAC3E,2CAAoD;AAYpD,gBAAgB;AAChB,MAAa,wBAAyB,SAAQ,0BAAgC;IAe5E,YAAY,EAAM,EAAE,MAAgB,EAAE,OAAgC;QACpE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEn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E,CAAC;YAC3D,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACzC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAhED,4DAgEC;AAcD,IAAA,yBAAa,EAAC,wBAAwB,EAAE;IACtC,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;CACvB,CAAC,CAAC"}

View file

@ -0,0 +1,38 @@
"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');
}
get commandName() {
return 'listDatabases';
}
async execute(server, session) {
const cmd = { listDatabases: 1 };
if (typeof this.options.nameOnly === 'boolean') {
cmd.nameOnly = this.options.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;
}
return await super.executeCommand(server, session, cmd);
}
}
exports.ListDatabasesOperation = ListDatabasesOperation;
(0, operation_1.defineAspects)(ListDatabasesOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE]);
//# sourceMappingURL=list_databases.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"list_databases.js","sourceRoot":"","sources":["../../src/operations/list_databases.ts"],"names":[],"mappings":";;;AAKA,oCAA4D;AAC5D,uCAA2E;AAC3E,2CAAoD;AAoBpD,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,0BAAqC;IAG/E,YAAY,EAAM,EAAE,OAA8B;Q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CAAC,CAAC,CAAC"}

69
BACK_BACK/node_modules/mongodb/lib/operations/operation.js generated vendored Executable file
View file

@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractOperation = exports.Aspect = void 0;
exports.defineAspects = defineAspects;
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.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 this.hasAspect(exports.Aspect.RETRYABLE) && this.hasAspect(exports.Aspect.READ_OPERATION);
}
get canRetryWrite() {
return this.hasAspect(exports.Aspect.RETRYABLE) && this.hasAspect(exports.Aspect.WRITE_OPERATION);
}
}
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;
}
//# sourceMappingURL=operation.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/operations/operation.ts"],"names":[],"mappings":";;;AA6GA,sCAeC;AA5HD,kCAAuF;AACvF,wDAA6E;AAKhE,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;AAsBX,gBAAgB;AAChB,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAEnC;;;;;;GAMG;AACH,MAAsB,iBAAiB;IAgBrC,YAAY,UAA4B,EAAE;QACxC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,cAAM,CAAC,eAAe,CAAC;YAC1D,CAAC,CAAC,gCAAc,CAAC,OAAO;YACxB,CAAC,CAAC,CAAC,gCAAc,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,gCAAc,CAAC,OAAO,CAAC,CAAC;QAEpE,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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AAC"}

View 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;
}
get commandName() {
return 'listCollections';
}
async execute(server, session) {
const coll = this.collection;
const [collection] = await coll.s.db
.listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session })
.toArray();
if (collection == null || collection.options == null) {
throw new error_1.MongoAPIError(`collection ${coll.namespace} not found`);
}
return collection.options;
}
}
exports.OptionsOperation = OptionsOperation;
//# sourceMappingURL=options_operation.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"options_operation.js","sourceRoot":"","sources":["../../src/operations/options_operation.ts"],"names":[],"mappings":";;;AAEA,oCAAyC;AAGzC,2CAAuE;AAEvE,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;IACD,IAAa,WAAW;QACtB,OAAO,iBAA0B,CAAC;IACpC,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAC7B,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE;aACjC,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,CAAC;QACb,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;YACrD,MAAM,IAAI,qBAAa,CAAC,cAAc,IAAI,CAAC,SAAS,YAAY,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,UAAU,CAAC,OAAO,CAAC;IAC5B,CAAC;CACF;AA1BD,4CA0BC"}

View 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;
}
get commandName() {
return 'profile';
}
async execute(server, session) {
const doc = await super.executeCommand(server, session, { profile: -1 });
if (doc.ok === 1) {
const was = doc.was;
if (was === 0)
return 'off';
if (was === 1)
return 'slow_only';
if (was === 2)
return 'all';
throw new error_1.MongoUnexpectedServerResponseError(`Illegal profiling level value ${was}`);
}
else {
throw new error_1.MongoUnexpectedServerResponseError('Error with profile command');
}
}
}
exports.ProfilingLevelOperation = ProfilingLevelOperation;
//# sourceMappingURL=profiling_level.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"profiling_level.js","sourceRoot":"","sources":["../../src/operations/profiling_level.ts"],"names":[],"mappings":";;;AACA,oCAA8D;AAG9D,uCAA2E;AAK3E,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;IAED,IAAa,WAAW;QACtB,OAAO,SAAkB,CAAC;IAC5B,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACzE,IAAI,GAAG,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;YACjB,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;YACpB,IAAI,GAAG,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC5B,IAAI,GAAG,KAAK,CAAC;gBAAE,OAAO,WAAW,CAAC;YAClC,IAAI,GAAG,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC5B,MAAM,IAAI,0CAAkC,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;QACvF,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,0CAAkC,CAAC,4BAA4B,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;CACF;AAxBD,0DAwBC"}

23
BACK_BACK/node_modules/mongodb/lib/operations/remove_user.js generated vendored Executable file
View file

@ -0,0 +1,23 @@
"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;
}
get commandName() {
return 'dropUser';
}
async execute(server, session) {
await super.executeCommand(server, session, { dropUser: this.username });
return true;
}
}
exports.RemoveUserOperation = RemoveUserOperation;
(0, operation_1.defineAspects)(RemoveUserOperation, [operation_1.Aspect.WRITE_OPERATION]);
//# sourceMappingURL=remove_user.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"remove_user.js","sourceRoot":"","sources":["../../src/operations/remove_user.ts"],"names":[],"mappings":";;;AAGA,uCAA2E;AAC3E,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;IAED,IAAa,WAAW;QACtB,OAAO,UAAmB,CAAC;IAC7B,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlBD,kDAkBC;AAED,IAAA,yBAAa,EAAC,mBAAmB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}

36
BACK_BACK/node_modules/mongodb/lib/operations/rename.js generated vendored Executable file
View file

@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RenameOperation = void 0;
const collection_1 = require("../collection");
const utils_1 = require("../utils");
const command_1 = require("./command");
const operation_1 = require("./operation");
/** @internal */
class RenameOperation extends command_1.CommandOperation {
constructor(collection, newName, options) {
super(collection, options);
this.collection = collection;
this.newName = newName;
this.options = options;
this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
}
get commandName() {
return 'renameCollection';
}
async execute(server, session) {
// Build the command
const renameCollection = this.collection.namespace;
const toCollection = this.collection.s.namespace.withCollection(this.newName).toString();
const dropTarget = typeof this.options.dropTarget === 'boolean' ? this.options.dropTarget : false;
const command = {
renameCollection: renameCollection,
to: toCollection,
dropTarget: dropTarget
};
await super.executeCommand(server, session, command);
return new collection_1.Collection(this.collection.s.db, this.newName, this.collection.s.options);
}
}
exports.RenameOperation = RenameOperation;
(0, operation_1.defineAspects)(RenameOperation, [operation_1.Aspect.WRITE_OPERATION]);
//# sourceMappingURL=rename.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../../src/operations/rename.ts"],"names":[],"mappings":";;;AACA,8CAA2C;AAG3C,oCAA4C;AAC5C,uCAA2E;AAC3E,2CAAoD;AAUpD,gBAAgB;AACh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AC"}

49
BACK_BACK/node_modules/mongodb/lib/operations/run_command.js generated vendored Executable file
View file

@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunAdminCommandOperation = exports.RunCommandOperation = void 0;
const utils_1 = require("../utils");
const operation_1 = require("./operation");
/** @internal */
class RunCommandOperation extends operation_1.AbstractOperation {
constructor(parent, command, options) {
super(options);
this.command = command;
this.options = options;
this.ns = parent.s.namespace.withCollection('$cmd');
}
get commandName() {
return 'runCommand';
}
async execute(server, session) {
this.server = server;
const res = await server.command(this.ns, this.command, {
...this.options,
readPreference: this.readPreference,
session
}, this.options.responseType);
return res;
}
}
exports.RunCommandOperation = RunCommandOperation;
class RunAdminCommandOperation extends operation_1.AbstractOperation {
constructor(command, options) {
super(options);
this.command = command;
this.options = options;
this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
}
get commandName() {
return 'runCommand';
}
async execute(server, session) {
this.server = server;
const res = await server.command(this.ns, this.command, {
...this.options,
readPreference: this.readPreference,
session
});
return res;
}
}
exports.RunAdminCommandOperation = RunAdminCommandOperation;
//# sourceMappingURL=run_command.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"run_command.js","sourceRoot":"","sources":["../../src/operations/run_command.ts"],"names":[],"mappings":";;;AAOA,oCAA4C;AAC5C,2CAAgD;AAUhD,gBAAgB;AAChB,MAAa,mBAAkC,SAAQ,6BAAoB;IACzE,YACE,MAAU,EACH,OAAiB,EACR,OAA0E;QAE1F,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,YAAO,GAAP,OAAO,CAAU;QACR,YAAO,GAAP,OAAO,CAAmE;QAG1F,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,YAAqB,CAAC;IAC/B,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,GAAG,GAAmB,MAAM,MAAM,CAAC,OAAO,CAC9C,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,OAAO,EACZ;YACE,GAAG,IAAI,CAAC,OAAO;YACf,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,OAAO;SACR,EACD,IAAI,CAAC,OAAO,CAAC,YAAY,CAC1B,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AA5BD,kDA4BC;AAED,MAAa,wBAAuC,SAAQ,6BAAoB;IAC9E,YACS,OAAiB,EACR,OAGf;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QANR,YAAO,GAAP,OAAO,CAAU;QACR,YAAO,GAAP,OAAO,CAGtB;QAGD,IAAI,CAAC,EAAE,GAAG,IAAI,wBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,YAAqB,CAAC;IAC/B,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,GAAG,GAAmB,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE;YACtE,GAAG,IAAI,CAAC,OAAO;YACf,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,OAAO;SACR,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAzBD,4DAyBC"}

View file

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateSearchIndexesOperation = void 0;
const operation_1 = require("../operation");
/** @internal */
class CreateSearchIndexesOperation extends operation_1.AbstractOperation {
constructor(collection, descriptions) {
super();
this.collection = collection;
this.descriptions = descriptions;
}
get commandName() {
return 'createSearchIndexes';
}
async execute(server, session) {
const namespace = this.collection.fullNamespace;
const command = {
createSearchIndexes: namespace.collection,
indexes: this.descriptions
};
const res = await server.command(namespace, command, { session });
const indexesCreated = res?.indexesCreated ?? [];
return indexesCreated.map(({ name }) => name);
}
}
exports.CreateSearchIndexesOperation = CreateSearchIndexesOperation;
//# sourceMappingURL=create.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/operations/search_indexes/create.ts"],"names":[],"mappings":";;;AAKA,4CAAiD;AAgBjD,gBAAgB;AAChB,MAAa,4BAA6B,SAAQ,6BAA2B;IAC3E,YACmB,UAAsB,EACtB,YAAmD;QAEpE,KAAK,EAAE,CAAC;QAHS,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAAuC;IAGtE,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,qBAA8B,CAAC;IACxC,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAChD,MAAM,OAAO,GAAG;YACd,mBAAmB,EAAE,SAAS,CAAC,UAAU;YACzC,OAAO,EAAE,IAAI,CAAC,YAAY;SAC3B,CAAC;QAEF,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAElE,MAAM,cAAc,GAA4B,GAAG,EAAE,cAAc,IAAI,EAAE,CAAC;QAC1E,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;CACF;AAxBD,oEAwBC"}

View file

@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DropSearchIndexOperation = void 0;
const error_1 = require("../../error");
const operation_1 = require("../operation");
/** @internal */
class DropSearchIndexOperation extends operation_1.AbstractOperation {
constructor(collection, name) {
super();
this.collection = collection;
this.name = name;
}
get commandName() {
return 'dropSearchIndex';
}
async execute(server, session) {
const namespace = this.collection.fullNamespace;
const command = {
dropSearchIndex: namespace.collection
};
if (typeof this.name === 'string') {
command.name = this.name;
}
try {
await server.command(namespace, command, { session });
}
catch (error) {
const isNamespaceNotFoundError = error instanceof error_1.MongoServerError && error.code === error_1.MONGODB_ERROR_CODES.NamespaceNotFound;
if (!isNamespaceNotFoundError) {
throw error;
}
}
}
}
exports.DropSearchIndexOperation = DropSearchIndexOperation;
//# sourceMappingURL=drop.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"drop.js","sourceRoot":"","sources":["../../../src/operations/search_indexes/drop.ts"],"names":[],"mappings":";;;AAGA,uCAAoE;AAGpE,4CAAiD;AAEjD,gBAAgB;AAChB,MAAa,wBAAyB,SAAQ,6BAAuB;IACnE,YACmB,UAAsB,EACtB,IAAY;QAE7B,KAAK,EAAE,CAAC;QAHS,eAAU,GAAV,UAAU,CAAY;QACtB,SAAI,GAAJ,IAAI,CAAQ;IAG/B,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,iBAA0B,CAAC;IACpC,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAEhD,MAAM,OAAO,GAAa;YACxB,eAAe,EAAE,SAAS,CAAC,UAAU;SACtC,CAAC;QAEF,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,wBAAwB,GAC5B,KAAK,YAAY,wBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,2BAAmB,CAAC,iBAAiB,CAAC;YAC5F,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAC9B,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAjCD,4DAiCC"}

View file

@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateSearchIndexOperation = void 0;
const operation_1 = require("../operation");
/** @internal */
class UpdateSearchIndexOperation extends operation_1.AbstractOperation {
constructor(collection, name, definition) {
super();
this.collection = collection;
this.name = name;
this.definition = definition;
}
get commandName() {
return 'updateSearchIndex';
}
async execute(server, session) {
const namespace = this.collection.fullNamespace;
const command = {
updateSearchIndex: namespace.collection,
name: this.name,
definition: this.definition
};
await server.command(namespace, command, { session });
return;
}
}
exports.UpdateSearchIndexOperation = UpdateSearchIndexOperation;
//# sourceMappingURL=update.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/operations/search_indexes/update.ts"],"names":[],"mappings":";;;AAKA,4CAAiD;AAEjD,gBAAgB;AAChB,MAAa,0BAA2B,SAAQ,6BAAuB;IACrE,YACmB,UAAsB,EACtB,IAAY,EACZ,UAAoB;QAErC,KAAK,EAAE,CAAC;QAJS,eAAU,GAAV,UAAU,CAAY;QACtB,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAU;IAGvC,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,mBAA4B,CAAC;IACtC,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAChD,MAAM,OAAO,GAAG;YACd,iBAAiB,EAAE,SAAS,CAAC,UAAU;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;QAEF,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACtD,OAAO;IACT,CAAC;CACF;AAxBD,gEAwBC"}

View file

@ -0,0 +1,49 @@
"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;
}
get commandName() {
return 'profile';
}
async execute(server, session) {
const level = this.level;
if (!levelValues.has(level)) {
throw new error_1.MongoInvalidArgumentError(`Profiling level must be one of "${(0, utils_1.enumToString)(exports.ProfilingLevel)}"`);
}
// TODO(NODE-3483): Determine error to put here
await super.executeCommand(server, session, { profile: this.profile });
return level;
}
}
exports.SetProfilingLevelOperation = SetProfilingLevelOperation;
//# sourceMappingURL=set_profiling_level.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"set_profiling_level.js","sourceRoot":"","sources":["../../src/operations/set_profiling_level.ts"],"names":[],"mappings":";;;AACA,oCAAqD;AAGrD,oCAAwC;AACxC,uCAA2E;AAE3E,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,CAAC;YACd,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;QACV,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,SAAkB,CAAC;IAC5B,CAAC;IAEQ,KAAK,CAAC,OAAO,CACpB,MAAc,EACd,OAAkC;QAElC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAEzB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,iCAAyB,CACjC,mCAAmC,IAAA,oBAAY,EAAC,sBAAc,CAAC,GAAG,CACnE,CAAC;QACJ,CAAC;QAED,+CAA+C;QAC/C,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA9CD,gEA8CC"}

25
BACK_BACK/node_modules/mongodb/lib/operations/stats.js generated vendored Executable file
View file

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DbStatsOperation = void 0;
const command_1 = require("./command");
const operation_1 = require("./operation");
/** @internal */
class DbStatsOperation extends command_1.CommandOperation {
constructor(db, options) {
super(db, options);
this.options = options;
}
get commandName() {
return 'dbStats';
}
async execute(server, session) {
const command = { dbStats: true };
if (this.options.scale != null) {
command.scale = this.options.scale;
}
return await super.executeCommand(server, session, command);
}
}
exports.DbStatsOperation = DbStatsOperation;
(0, operation_1.defineAspects)(DbStatsOperation, [operation_1.Aspect.READ_OPERATION]);
//# sourceMappingURL=stats.js.map

1
BACK_BACK/node_modules/mongodb/lib/operations/stats.js.map generated vendored Executable file
View file

@ -0,0 +1 @@
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/operations/stats.ts"],"names":[],"mappings":";;;AAIA,uCAA2E;AAC3E,2CAAoD;AAQpD,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;IAED,IAAa,WAAW;QACtB,OAAO,SAAkB,CAAC;IAC5B,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAkC;QACvE,MAAM,OAAO,GAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACrC,CAAC;QAED,OAAO,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;CACF;AApBD,4CAoBC;AAED,IAAA,yBAAa,EAAC,gBAAgB,EAAE,CAAC,kBAAM,CAAC,cAAc,CAAC,CAAC,CAAC"}

180
BACK_BACK/node_modules/mongodb/lib/operations/update.js generated vendored Executable file
View file

@ -0,0 +1,180 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReplaceOneOperation = exports.UpdateManyOperation = exports.UpdateOneOperation = exports.UpdateOperation = void 0;
exports.makeUpdateStatement = makeUpdateStatement;
const error_1 = require("../error");
const utils_1 = require("../utils");
const command_1 = require("./command");
const operation_1 = require("./operation");
/**
* @internal
* UpdateOperation is used in bulk write, while UpdateOneOperation and UpdateManyOperation are only used in the collections API
*/
class UpdateOperation extends command_1.CommandOperation {
constructor(ns, statements, options) {
super(undefined, options);
this.options = options;
this.ns = ns;
this.statements = statements;
}
get commandName() {
return 'update';
}
get canRetryWrite() {
if (super.canRetryWrite === false) {
return false;
}
return this.statements.every(op => op.multi == null || op.multi === false);
}
async execute(server, session) {
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
throw new error_1.MongoCompatibilityError(`hint is not supported with unacknowledged writes`);
}
}
const res = await super.executeCommand(server, session, command);
return res;
}
}
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');
}
}
async execute(server, session) {
const res = await super.execute(server, session);
if (this.explain != null)
return res;
if (res.code)
throw new error_1.MongoServerError(res);
if (res.writeErrors)
throw new error_1.MongoServerError(res.writeErrors[0]);
return {
acknowledged: this.writeConcern?.w !== 0,
modifiedCount: 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');
}
}
async execute(server, session) {
const res = await super.execute(server, session);
if (this.explain != null)
return res;
if (res.code)
throw new error_1.MongoServerError(res);
if (res.writeErrors)
throw new error_1.MongoServerError(res.writeErrors[0]);
return {
acknowledged: this.writeConcern?.w !== 0,
modifiedCount: 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');
}
}
async execute(server, session) {
const res = await super.execute(server, session);
if (this.explain != null)
return res;
if (res.code)
throw new error_1.MongoServerError(res);
if (res.writeErrors)
throw new error_1.MongoServerError(res.writeErrors[0]);
return {
acknowledged: this.writeConcern?.w !== 0,
modifiedCount: 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;
}
(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

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,38 @@
"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;
}
get commandName() {
return 'validate';
}
async execute(server, session) {
const collectionName = this.collectionName;
const doc = await super.executeCommand(server, session, this.command);
if (doc.result != null && typeof doc.result !== 'string')
throw new error_1.MongoUnexpectedServerResponseError('Error with validation data');
if (doc.result != null && doc.result.match(/exception|corrupt/) != null)
throw new error_1.MongoUnexpectedServerResponseError(`Invalid collection ${collectionName}`);
if (doc.valid != null && !doc.valid)
throw new error_1.MongoUnexpectedServerResponseError(`Invalid collection ${collectionName}`);
return doc;
}
}
exports.ValidateCollectionOperation = ValidateCollectionOperation;
//# sourceMappingURL=validate_collection.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"validate_collection.js","sourceRoot":"","sources":["../../src/operations/validate_collection.ts"],"names":[],"mappings":";;;AAEA,oCAA8D;AAG9D,uCAA2E;AAQ3E,gBAAgB;AAChB,MAAa,2BAA4B,SAAQ,0BAA0B;IAKzE,YAAY,KAAY,EAAE,cAAsB,EAAE,OAAkC;QAClF,sCAAsC;QACtC,MAAM,OAAO,GAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;gBACpF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAI,OAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,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