mongodb 6.18.0 → 6.19.0-dev.20250827.sha.3c5bb1d5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/admin.js +2 -1
- package/lib/admin.js.map +1 -1
- package/lib/beta.d.ts +59 -7
- package/lib/bulk/common.js +19 -32
- package/lib/bulk/common.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +4 -1
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/state_machine.js +4 -0
- package/lib/client-side-encryption/state_machine.js.map +1 -1
- package/lib/cmap/connection.js.map +1 -1
- package/lib/collection.js +62 -19
- package/lib/collection.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +2 -1
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/explainable_cursor.js +36 -0
- package/lib/cursor/explainable_cursor.js.map +1 -0
- package/lib/cursor/find_cursor.js +2 -1
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/cursor/run_command_cursor.js +2 -4
- package/lib/cursor/run_command_cursor.js.map +1 -1
- package/lib/db.js +12 -5
- package/lib/db.js.map +1 -1
- package/lib/explain.js +1 -33
- package/lib/explain.js.map +1 -1
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +25 -2
- package/lib/mongo_client.js.map +1 -1
- package/lib/operations/aggregate.js +9 -7
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/client_bulk_write/client_bulk_write.js +8 -41
- package/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -1
- package/lib/operations/command.js +16 -19
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/count.js +7 -3
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/create_collection.js +56 -49
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/delete.js +15 -12
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js +18 -26
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/drop.js +57 -39
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/estimated_document_count.js +7 -3
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/execute_operation.js +14 -3
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +21 -30
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +52 -41
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/get_more.js +10 -11
- package/lib/operations/get_more.js.map +1 -1
- package/lib/operations/indexes.js +21 -12
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +8 -47
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/kill_cursors.js +13 -15
- package/lib/operations/kill_cursors.js.map +1 -1
- package/lib/operations/list_collections.js +7 -6
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/list_databases.js +5 -3
- package/lib/operations/list_databases.js.map +1 -1
- package/lib/operations/operation.js +30 -1
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/profiling_level.js +14 -4
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/remove_user.js +6 -2
- package/lib/operations/remove_user.js.map +1 -1
- package/lib/operations/rename.js +10 -8
- package/lib/operations/rename.js.map +1 -1
- package/lib/operations/run_command.js +28 -32
- package/lib/operations/run_command.js.map +1 -1
- package/lib/operations/search_indexes/create.js +11 -8
- package/lib/operations/search_indexes/create.js.map +1 -1
- package/lib/operations/search_indexes/drop.js +16 -9
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/operations/search_indexes/update.js +11 -4
- package/lib/operations/search_indexes/update.js.map +1 -1
- package/lib/operations/set_profiling_level.js +8 -4
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/stats.js +4 -2
- package/lib/operations/stats.js.map +1 -1
- package/lib/operations/update.js +22 -19
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js +17 -18
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/sdam/server.js +46 -35
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/topology.js +4 -3
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sessions.js +3 -3
- package/lib/sessions.js.map +1 -1
- package/lib/utils.js +8 -13
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +59 -7
- package/package.json +19 -19
- package/src/admin.ts +3 -2
- package/src/bulk/common.ts +21 -41
- package/src/client-side-encryption/client_encryption.ts +52 -3
- package/src/client-side-encryption/state_machine.ts +5 -1
- package/src/cmap/connection.ts +0 -1
- package/src/collection.ts +94 -65
- package/src/cursor/aggregation_cursor.ts +1 -1
- package/src/cursor/explainable_cursor.ts +51 -0
- package/src/cursor/find_cursor.ts +1 -1
- package/src/cursor/run_command_cursor.ts +4 -5
- package/src/db.ts +16 -19
- package/src/explain.ts +0 -49
- package/src/index.ts +4 -4
- package/src/mongo_client.ts +24 -9
- package/src/operations/aggregate.ts +15 -20
- package/src/operations/client_bulk_write/client_bulk_write.ts +21 -65
- package/src/operations/command.ts +22 -45
- package/src/operations/count.ts +9 -9
- package/src/operations/create_collection.ts +83 -75
- package/src/operations/delete.ts +27 -35
- package/src/operations/distinct.ts +23 -40
- package/src/operations/drop.ts +76 -60
- package/src/operations/estimated_document_count.ts +8 -9
- package/src/operations/execute_operation.ts +21 -11
- package/src/operations/find.ts +40 -57
- package/src/operations/find_and_modify.ts +78 -54
- package/src/operations/get_more.ts +17 -19
- package/src/operations/indexes.ts +26 -30
- package/src/operations/insert.ts +11 -77
- package/src/operations/kill_cursors.ts +21 -22
- package/src/operations/list_collections.ts +13 -21
- package/src/operations/list_databases.ts +6 -15
- package/src/operations/operation.ts +47 -10
- package/src/operations/profiling_level.ts +17 -11
- package/src/operations/remove_user.ts +9 -9
- package/src/operations/rename.ts +11 -14
- package/src/operations/run_command.ts +40 -68
- package/src/operations/search_indexes/create.ts +15 -15
- package/src/operations/search_indexes/drop.ts +23 -14
- package/src/operations/search_indexes/update.ts +14 -9
- package/src/operations/set_profiling_level.ts +13 -11
- package/src/operations/stats.ts +5 -10
- package/src/operations/update.ts +49 -52
- package/src/operations/validate_collection.ts +19 -27
- package/src/sdam/server.ts +56 -59
- package/src/sdam/topology.ts +5 -4
- package/src/sessions.ts +5 -4
- package/src/utils.ts +10 -25
- package/lib/operations/bulk_write.js +0 -39
- package/lib/operations/bulk_write.js.map +0 -1
- package/lib/operations/collections.js +0 -33
- package/lib/operations/collections.js.map +0 -1
- package/lib/operations/is_capped.js +0 -28
- package/lib/operations/is_capped.js.map +0 -1
- package/lib/operations/options_operation.js +0 -28
- package/lib/operations/options_operation.js.map +0 -1
- package/src/operations/bulk_write.ts +0 -64
- package/src/operations/collections.ts +0 -47
- package/src/operations/is_capped.ts +0 -35
- package/src/operations/options_operation.ts +0 -35
package/src/utils.ts
CHANGED
|
@@ -1357,38 +1357,23 @@ export async function once<T>(ee: EventEmitter, name: string, options?: Abortabl
|
|
|
1357
1357
|
}
|
|
1358
1358
|
|
|
1359
1359
|
export function maybeAddIdToDocuments(
|
|
1360
|
-
|
|
1361
|
-
|
|
1360
|
+
collection: Collection,
|
|
1361
|
+
document: Document,
|
|
1362
1362
|
options: { forceServerObjectId?: boolean }
|
|
1363
|
-
): Document
|
|
1364
|
-
export function maybeAddIdToDocuments(
|
|
1365
|
-
coll: Collection,
|
|
1366
|
-
docs: Document,
|
|
1367
|
-
options: { forceServerObjectId?: boolean }
|
|
1368
|
-
): Document;
|
|
1369
|
-
export function maybeAddIdToDocuments(
|
|
1370
|
-
coll: Collection,
|
|
1371
|
-
docOrDocs: Document[] | Document,
|
|
1372
|
-
options: { forceServerObjectId?: boolean }
|
|
1373
|
-
): Document[] | Document {
|
|
1363
|
+
): Document {
|
|
1374
1364
|
const forceServerObjectId =
|
|
1375
|
-
|
|
1376
|
-
? options.forceServerObjectId
|
|
1377
|
-
: coll.s.db.options?.forceServerObjectId;
|
|
1365
|
+
options.forceServerObjectId ?? collection.s.db.options?.forceServerObjectId ?? false;
|
|
1378
1366
|
|
|
1379
1367
|
// no need to modify the docs if server sets the ObjectId
|
|
1380
|
-
if (forceServerObjectId
|
|
1381
|
-
return
|
|
1368
|
+
if (forceServerObjectId) {
|
|
1369
|
+
return document;
|
|
1382
1370
|
}
|
|
1383
1371
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
}
|
|
1372
|
+
if (document._id == null) {
|
|
1373
|
+
document._id = collection.s.pkFactory.createPk();
|
|
1374
|
+
}
|
|
1388
1375
|
|
|
1389
|
-
|
|
1390
|
-
};
|
|
1391
|
-
return Array.isArray(docOrDocs) ? docOrDocs.map(transform) : transform(docOrDocs);
|
|
1376
|
+
return document;
|
|
1392
1377
|
}
|
|
1393
1378
|
|
|
1394
1379
|
export async function fileIsAccessible(fileName: string, mode?: number) {
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BulkWriteOperation = void 0;
|
|
4
|
-
const operation_1 = require("./operation");
|
|
5
|
-
/** @internal */
|
|
6
|
-
class BulkWriteOperation extends operation_1.AbstractOperation {
|
|
7
|
-
constructor(collection, operations, options) {
|
|
8
|
-
super(options);
|
|
9
|
-
this.options = options;
|
|
10
|
-
this.collection = collection;
|
|
11
|
-
this.operations = operations;
|
|
12
|
-
}
|
|
13
|
-
get commandName() {
|
|
14
|
-
return 'bulkWrite';
|
|
15
|
-
}
|
|
16
|
-
async execute(server, session, timeoutContext) {
|
|
17
|
-
const coll = this.collection;
|
|
18
|
-
const operations = this.operations;
|
|
19
|
-
const options = {
|
|
20
|
-
...this.options,
|
|
21
|
-
...this.bsonOptions,
|
|
22
|
-
readPreference: this.readPreference,
|
|
23
|
-
timeoutContext
|
|
24
|
-
};
|
|
25
|
-
// Create the bulk operation
|
|
26
|
-
const bulk = options.ordered === false
|
|
27
|
-
? coll.initializeUnorderedBulkOp(options)
|
|
28
|
-
: coll.initializeOrderedBulkOp(options);
|
|
29
|
-
// for each op go through and add to the bulk
|
|
30
|
-
for (let i = 0; i < operations.length; i++) {
|
|
31
|
-
bulk.raw(operations[i]);
|
|
32
|
-
}
|
|
33
|
-
// Execute the bulk
|
|
34
|
-
return await bulk.execute({ ...options, session });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.BulkWriteOperation = BulkWriteOperation;
|
|
38
|
-
(0, operation_1.defineAspects)(BulkWriteOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
|
39
|
-
//# sourceMappingURL=bulk_write.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bulk_write.js","sourceRoot":"","sources":["../../src/operations/bulk_write.ts"],"names":[],"mappings":";;;AAUA,2CAAuE;AAEvE,gBAAgB;AAChB,MAAa,kBAAmB,SAAQ,6BAAkC;IAKxE,YACE,UAAsB,EACtB,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,EAClC,cAA8B;QAE9B,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,MAAM,OAAO,GAAG;YACd,GAAG,IAAI,CAAC,OAAO;YACf,GAAG,IAAI,CAAC,WAAW;YACnB,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,cAAc;SACf,CAAC;QAEF,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;AAhDD,gDAgDC;AAED,IAAA,yBAAa,EAAC,kBAAkB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CollectionsOperation = void 0;
|
|
4
|
-
const collection_1 = require("../collection");
|
|
5
|
-
const operation_1 = require("./operation");
|
|
6
|
-
/** @internal */
|
|
7
|
-
class CollectionsOperation extends operation_1.AbstractOperation {
|
|
8
|
-
constructor(db, options) {
|
|
9
|
-
super(options);
|
|
10
|
-
this.options = options;
|
|
11
|
-
this.db = db;
|
|
12
|
-
}
|
|
13
|
-
get commandName() {
|
|
14
|
-
return 'listCollections';
|
|
15
|
-
}
|
|
16
|
-
async execute(server, session) {
|
|
17
|
-
// Let's get the collection names
|
|
18
|
-
const documents = await this.db
|
|
19
|
-
.listCollections({}, { ...this.options, nameOnly: true, readPreference: this.readPreference, session })
|
|
20
|
-
.toArray();
|
|
21
|
-
const collections = [];
|
|
22
|
-
for (const { name } of documents) {
|
|
23
|
-
if (!name.includes('$')) {
|
|
24
|
-
// Filter collections removing any illegal ones
|
|
25
|
-
collections.push(new collection_1.Collection(this.db, name, this.db.s.options));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// Return the collection objects
|
|
29
|
-
return collections;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.CollectionsOperation = CollectionsOperation;
|
|
33
|
-
//# sourceMappingURL=collections.js.map
|
|
@@ -1 +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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsCappedOperation = void 0;
|
|
4
|
-
const error_1 = require("../error");
|
|
5
|
-
const operation_1 = require("./operation");
|
|
6
|
-
/** @internal */
|
|
7
|
-
class IsCappedOperation extends operation_1.AbstractOperation {
|
|
8
|
-
constructor(collection, options) {
|
|
9
|
-
super(options);
|
|
10
|
-
this.options = options;
|
|
11
|
-
this.collection = collection;
|
|
12
|
-
}
|
|
13
|
-
get commandName() {
|
|
14
|
-
return 'listCollections';
|
|
15
|
-
}
|
|
16
|
-
async execute(server, session) {
|
|
17
|
-
const coll = this.collection;
|
|
18
|
-
const [collection] = await coll.s.db
|
|
19
|
-
.listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session })
|
|
20
|
-
.toArray();
|
|
21
|
-
if (collection == null || collection.options == null) {
|
|
22
|
-
throw new error_1.MongoAPIError(`collection ${coll.namespace} not found`);
|
|
23
|
-
}
|
|
24
|
-
return !!collection.options?.capped;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.IsCappedOperation = IsCappedOperation;
|
|
28
|
-
//# sourceMappingURL=is_capped.js.map
|
|
@@ -1 +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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OptionsOperation = void 0;
|
|
4
|
-
const error_1 = require("../error");
|
|
5
|
-
const operation_1 = require("./operation");
|
|
6
|
-
/** @internal */
|
|
7
|
-
class OptionsOperation extends operation_1.AbstractOperation {
|
|
8
|
-
constructor(collection, options) {
|
|
9
|
-
super(options);
|
|
10
|
-
this.options = options;
|
|
11
|
-
this.collection = collection;
|
|
12
|
-
}
|
|
13
|
-
get commandName() {
|
|
14
|
-
return 'listCollections';
|
|
15
|
-
}
|
|
16
|
-
async execute(server, session) {
|
|
17
|
-
const coll = this.collection;
|
|
18
|
-
const [collection] = await coll.s.db
|
|
19
|
-
.listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session })
|
|
20
|
-
.toArray();
|
|
21
|
-
if (collection == null || collection.options == null) {
|
|
22
|
-
throw new error_1.MongoAPIError(`collection ${coll.namespace} not found`);
|
|
23
|
-
}
|
|
24
|
-
return collection.options;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.OptionsOperation = OptionsOperation;
|
|
28
|
-
//# sourceMappingURL=options_operation.js.map
|
|
@@ -1 +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"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnyBulkWriteOperation,
|
|
3
|
-
BulkOperationBase,
|
|
4
|
-
BulkWriteOptions,
|
|
5
|
-
BulkWriteResult
|
|
6
|
-
} from '../bulk/common';
|
|
7
|
-
import type { Collection } from '../collection';
|
|
8
|
-
import type { Server } from '../sdam/server';
|
|
9
|
-
import type { ClientSession } from '../sessions';
|
|
10
|
-
import { type TimeoutContext } from '../timeout';
|
|
11
|
-
import { AbstractOperation, Aspect, defineAspects } from './operation';
|
|
12
|
-
|
|
13
|
-
/** @internal */
|
|
14
|
-
export class BulkWriteOperation extends AbstractOperation<BulkWriteResult> {
|
|
15
|
-
override options: BulkWriteOptions;
|
|
16
|
-
collection: Collection;
|
|
17
|
-
operations: ReadonlyArray<AnyBulkWriteOperation>;
|
|
18
|
-
|
|
19
|
-
constructor(
|
|
20
|
-
collection: Collection,
|
|
21
|
-
operations: ReadonlyArray<AnyBulkWriteOperation>,
|
|
22
|
-
options: BulkWriteOptions
|
|
23
|
-
) {
|
|
24
|
-
super(options);
|
|
25
|
-
this.options = options;
|
|
26
|
-
this.collection = collection;
|
|
27
|
-
this.operations = operations;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override get commandName() {
|
|
31
|
-
return 'bulkWrite' as const;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override async execute(
|
|
35
|
-
server: Server,
|
|
36
|
-
session: ClientSession | undefined,
|
|
37
|
-
timeoutContext: TimeoutContext
|
|
38
|
-
): Promise<BulkWriteResult> {
|
|
39
|
-
const coll = this.collection;
|
|
40
|
-
const operations = this.operations;
|
|
41
|
-
const options = {
|
|
42
|
-
...this.options,
|
|
43
|
-
...this.bsonOptions,
|
|
44
|
-
readPreference: this.readPreference,
|
|
45
|
-
timeoutContext
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// Create the bulk operation
|
|
49
|
-
const bulk: BulkOperationBase =
|
|
50
|
-
options.ordered === false
|
|
51
|
-
? coll.initializeUnorderedBulkOp(options)
|
|
52
|
-
: coll.initializeOrderedBulkOp(options);
|
|
53
|
-
|
|
54
|
-
// for each op go through and add to the bulk
|
|
55
|
-
for (let i = 0; i < operations.length; i++) {
|
|
56
|
-
bulk.raw(operations[i]);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Execute the bulk
|
|
60
|
-
return await bulk.execute({ ...options, session });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
defineAspects(BulkWriteOperation, [Aspect.WRITE_OPERATION]);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Collection } from '../collection';
|
|
2
|
-
import type { Db } from '../db';
|
|
3
|
-
import type { Server } from '../sdam/server';
|
|
4
|
-
import type { ClientSession } from '../sessions';
|
|
5
|
-
import { AbstractOperation, type OperationOptions } from './operation';
|
|
6
|
-
|
|
7
|
-
export interface CollectionsOptions extends OperationOptions {
|
|
8
|
-
nameOnly?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export class CollectionsOperation extends AbstractOperation<Collection[]> {
|
|
13
|
-
override options: CollectionsOptions;
|
|
14
|
-
db: Db;
|
|
15
|
-
|
|
16
|
-
constructor(db: Db, options: CollectionsOptions) {
|
|
17
|
-
super(options);
|
|
18
|
-
this.options = options;
|
|
19
|
-
this.db = db;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
override get commandName() {
|
|
23
|
-
return 'listCollections' as const;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
override async execute(
|
|
27
|
-
server: Server,
|
|
28
|
-
session: ClientSession | undefined
|
|
29
|
-
): Promise<Collection[]> {
|
|
30
|
-
// Let's get the collection names
|
|
31
|
-
const documents = await this.db
|
|
32
|
-
.listCollections(
|
|
33
|
-
{},
|
|
34
|
-
{ ...this.options, nameOnly: true, readPreference: this.readPreference, session }
|
|
35
|
-
)
|
|
36
|
-
.toArray();
|
|
37
|
-
const collections: Collection[] = [];
|
|
38
|
-
for (const { name } of documents) {
|
|
39
|
-
if (!name.includes('$')) {
|
|
40
|
-
// Filter collections removing any illegal ones
|
|
41
|
-
collections.push(new Collection(this.db, name, this.db.s.options));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Return the collection objects
|
|
45
|
-
return collections;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Collection } from '../collection';
|
|
2
|
-
import { MongoAPIError } from '../error';
|
|
3
|
-
import type { Server } from '../sdam/server';
|
|
4
|
-
import type { ClientSession } from '../sessions';
|
|
5
|
-
import { AbstractOperation, type OperationOptions } from './operation';
|
|
6
|
-
|
|
7
|
-
/** @internal */
|
|
8
|
-
export class IsCappedOperation extends AbstractOperation<boolean> {
|
|
9
|
-
override options: OperationOptions;
|
|
10
|
-
collection: Collection;
|
|
11
|
-
|
|
12
|
-
constructor(collection: Collection, options: OperationOptions) {
|
|
13
|
-
super(options);
|
|
14
|
-
this.options = options;
|
|
15
|
-
this.collection = collection;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override get commandName() {
|
|
19
|
-
return 'listCollections' as const;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
override async execute(server: Server, session: ClientSession | undefined): Promise<boolean> {
|
|
23
|
-
const coll = this.collection;
|
|
24
|
-
const [collection] = await coll.s.db
|
|
25
|
-
.listCollections(
|
|
26
|
-
{ name: coll.collectionName },
|
|
27
|
-
{ ...this.options, nameOnly: false, readPreference: this.readPreference, session }
|
|
28
|
-
)
|
|
29
|
-
.toArray();
|
|
30
|
-
if (collection == null || collection.options == null) {
|
|
31
|
-
throw new MongoAPIError(`collection ${coll.namespace} not found`);
|
|
32
|
-
}
|
|
33
|
-
return !!collection.options?.capped;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Document } from '../bson';
|
|
2
|
-
import type { Collection } from '../collection';
|
|
3
|
-
import { MongoAPIError } from '../error';
|
|
4
|
-
import type { Server } from '../sdam/server';
|
|
5
|
-
import type { ClientSession } from '../sessions';
|
|
6
|
-
import { AbstractOperation, type OperationOptions } from './operation';
|
|
7
|
-
|
|
8
|
-
/** @internal */
|
|
9
|
-
export class OptionsOperation extends AbstractOperation<Document> {
|
|
10
|
-
override options: OperationOptions;
|
|
11
|
-
collection: Collection;
|
|
12
|
-
|
|
13
|
-
constructor(collection: Collection, options: OperationOptions) {
|
|
14
|
-
super(options);
|
|
15
|
-
this.options = options;
|
|
16
|
-
this.collection = collection;
|
|
17
|
-
}
|
|
18
|
-
override get commandName() {
|
|
19
|
-
return 'listCollections' as const;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
override async execute(server: Server, session: ClientSession | undefined): Promise<Document> {
|
|
23
|
-
const coll = this.collection;
|
|
24
|
-
const [collection] = await coll.s.db
|
|
25
|
-
.listCollections(
|
|
26
|
-
{ name: coll.collectionName },
|
|
27
|
-
{ ...this.options, nameOnly: false, readPreference: this.readPreference, session }
|
|
28
|
-
)
|
|
29
|
-
.toArray();
|
|
30
|
-
if (collection == null || collection.options == null) {
|
|
31
|
-
throw new MongoAPIError(`collection ${coll.namespace} not found`);
|
|
32
|
-
}
|
|
33
|
-
return collection.options;
|
|
34
|
-
}
|
|
35
|
-
}
|