mongodb 6.8.0-dev.20240905.sha.65e0e15c → 6.8.1
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/README.md +1 -14
- package/lib/bson.js +13 -4
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +21 -16
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/ordered.js.map +1 -1
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +8 -10
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +3 -14
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +7 -25
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/crypto_callbacks.js +6 -6
- package/lib/client-side-encryption/crypto_callbacks.js.map +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js +5 -9
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
- package/lib/client-side-encryption/providers/aws.js +2 -1
- package/lib/client-side-encryption/providers/aws.js.map +1 -1
- package/lib/client-side-encryption/providers/azure.js +5 -5
- package/lib/client-side-encryption/providers/azure.js.map +1 -1
- package/lib/client-side-encryption/providers/gcp.js +2 -1
- package/lib/client-side-encryption/providers/gcp.js.map +1 -1
- package/lib/client-side-encryption/providers/index.js +3 -2
- package/lib/client-side-encryption/providers/index.js.map +1 -1
- package/lib/client-side-encryption/state_machine.js +4 -9
- package/lib/client-side-encryption/state_machine.js.map +1 -1
- package/lib/cmap/auth/auth_provider.js.map +1 -1
- package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +4 -4
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongocr.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +2 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/command_builders.js +3 -2
- package/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +2 -0
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
- package/lib/cmap/auth/plain.js.map +1 -1
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/auth/x509.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +5 -62
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +7 -9
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +5 -3
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +9 -11
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/connection_pool_events.js +3 -7
- package/lib/cmap/connection_pool_events.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +5 -5
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/metrics.js +1 -1
- package/lib/cmap/metrics.js.map +1 -1
- package/lib/cmap/stream_description.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +5 -5
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +2 -2
- package/lib/cmap/wire_protocol/on_data.js +2 -1
- package/lib/cmap/wire_protocol/on_data.js.map +1 -1
- package/lib/cmap/wire_protocol/on_demand/document.js +3 -12
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
- package/lib/cmap/wire_protocol/responses.js +15 -6
- package/lib/cmap/wire_protocol/responses.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js +3 -2
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +5 -10
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +16 -25
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +2 -2
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/change_stream_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +4 -4
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/db.js +1 -1
- package/lib/db.js.map +1 -1
- package/lib/deps.js +8 -16
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +14 -19
- package/lib/error.js.map +1 -1
- package/lib/explain.js.map +1 -1
- package/lib/gridfs/download.js +4 -1
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +1 -1
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +4 -0
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +1 -15
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_client_auth_providers.js.map +1 -1
- package/lib/mongo_logger.js +8 -8
- package/lib/mongo_logger.js.map +1 -1
- package/lib/mongo_types.js +0 -1
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/aggregate.js +0 -1
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/bulk_write.js.map +1 -1
- package/lib/operations/collections.js.map +1 -1
- package/lib/operations/command.js +1 -1
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/delete.js +2 -2
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/execute_operation.js +109 -111
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +8 -2
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/get_more.js.map +1 -1
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/is_capped.js.map +1 -1
- package/lib/operations/kill_cursors.js.map +1 -1
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/list_databases.js.map +1 -1
- package/lib/operations/operation.js +5 -5
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/options_operation.js.map +1 -1
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/stats.js.map +1 -1
- package/lib/operations/update.js +2 -2
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/read_concern.js.map +1 -1
- package/lib/read_preference.js +1 -1
- package/lib/read_preference.js.map +1 -1
- package/lib/sdam/common.js +3 -3
- package/lib/sdam/common.js.map +1 -1
- package/lib/sdam/monitor.js +5 -1
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +2 -2
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +3 -3
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +5 -5
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +3 -2
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +1 -1
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +218 -221
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +3 -2
- package/lib/sort.js.map +1 -1
- package/lib/timeout.js +1 -0
- package/lib/timeout.js.map +1 -1
- package/lib/transactions.js +2 -2
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +51 -49
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js +2 -2
- package/lib/write_concern.js.map +1 -1
- package/mongodb.d.ts +143 -146
- package/package.json +28 -27
- package/src/bson.ts +13 -1
- package/src/bulk/common.ts +18 -18
- package/src/change_stream.ts +15 -33
- package/src/client-side-encryption/auto_encrypter.ts +82 -18
- package/src/client-side-encryption/client_encryption.ts +54 -51
- package/src/client-side-encryption/mongocryptd_manager.ts +6 -10
- package/src/client-side-encryption/state_machine.ts +6 -28
- package/src/cmap/auth/gssapi.ts +1 -1
- package/src/cmap/auth/mongodb_aws.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +2 -2
- package/src/cmap/commands.ts +5 -70
- package/src/cmap/connect.ts +1 -3
- package/src/cmap/connection.ts +4 -3
- package/src/cmap/connection_pool.ts +9 -17
- package/src/cmap/connection_pool_events.ts +2 -34
- package/src/cmap/handshake/client_metadata.ts +1 -1
- package/src/cmap/wire_protocol/constants.ts +2 -2
- package/src/cmap/wire_protocol/on_demand/document.ts +14 -18
- package/src/cmap/wire_protocol/responses.ts +23 -5
- package/src/cmap/wire_protocol/shared.ts +2 -1
- package/src/collection.ts +15 -16
- package/src/connection_string.ts +2 -8
- package/src/constants.ts +0 -1
- package/src/cursor/abstract_cursor.ts +28 -42
- package/src/cursor/aggregation_cursor.ts +5 -7
- package/src/cursor/find_cursor.ts +1 -1
- package/src/deps.ts +1 -8
- package/src/error.ts +14 -33
- package/src/gridfs/download.ts +4 -28
- package/src/gridfs/upload.ts +6 -1
- package/src/index.ts +6 -6
- package/src/mongo_client.ts +3 -25
- package/src/mongo_logger.ts +3 -5
- package/src/mongo_types.ts +68 -69
- package/src/operations/aggregate.ts +1 -2
- package/src/operations/bulk_write.ts +2 -2
- package/src/operations/command.ts +1 -1
- package/src/operations/execute_operation.ts +131 -137
- package/src/operations/find_and_modify.ts +7 -2
- package/src/operations/insert.ts +4 -3
- package/src/operations/operation.ts +10 -7
- package/src/operations/search_indexes/drop.ts +1 -4
- package/src/sdam/monitor.ts +5 -3
- package/src/sdam/server.ts +1 -1
- package/src/sdam/server_description.ts +6 -5
- package/src/sdam/srv_polling.ts +2 -1
- package/src/sessions.ts +277 -291
- package/src/sort.ts +1 -1
- package/src/timeout.ts +1 -0
- package/src/transactions.ts +2 -1
- package/src/utils.ts +4 -9
- package/src/write_concern.ts +2 -2
- package/tsconfig.json +1 -2
- package/lib/beta.d.ts +0 -7900
- package/lib/beta.js +0 -21
- package/lib/beta.js.map +0 -1
- package/lib/operations/client_bulk_write/command_builder.js +0 -198
- package/lib/operations/client_bulk_write/command_builder.js.map +0 -1
- package/lib/operations/client_bulk_write/common.js +0 -3
- package/lib/operations/client_bulk_write/common.js.map +0 -1
- package/lib/resource_management.js +0 -58
- package/lib/resource_management.js.map +0 -1
- package/src/beta.ts +0 -22
- package/src/operations/client_bulk_write/command_builder.ts +0 -283
- package/src/operations/client_bulk_write/common.ts +0 -146
- package/src/resource_management.ts +0 -74
package/lib/beta.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
__exportStar(require("./index"), exports);
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*
|
|
7
|
-
* Since we don't bundle tslib helpers, we need to polyfill this method.
|
|
8
|
-
*
|
|
9
|
-
* This is used in the generated JS. Adapted from https://github.com/microsoft/TypeScript/blob/aafdfe5b3f76f5c41abeec412ce73c86da94c75f/src/compiler/factory/emitHelpers.ts#L1202.
|
|
10
|
-
*/
|
|
11
|
-
function __exportStar(mod) {
|
|
12
|
-
for (const key of Object.keys(mod)) {
|
|
13
|
-
Object.defineProperty(exports, key, {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return mod[key];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=beta.js.map
|
package/lib/beta.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"beta.js","sourceRoot":"","sources":["../src/beta.ts"],"names":[],"mappings":";;AAEA,0CAAwB;AAExB;;;;;;GAMG;AAEH,SAAS,YAAY,CAAC,GAAa;IACjC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE;gBACH,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;YAClB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildReplaceOneOperation = exports.buildUpdateManyOperation = exports.buildUpdateOneOperation = exports.buildDeleteManyOperation = exports.buildDeleteOneOperation = exports.buildInsertOneOperation = exports.ClientBulkWriteCommandBuilder = void 0;
|
|
4
|
-
exports.buildOperation = buildOperation;
|
|
5
|
-
const commands_1 = require("../../cmap/commands");
|
|
6
|
-
/** @internal */
|
|
7
|
-
class ClientBulkWriteCommandBuilder {
|
|
8
|
-
/**
|
|
9
|
-
* Create the command builder.
|
|
10
|
-
* @param models - The client write models.
|
|
11
|
-
*/
|
|
12
|
-
constructor(models, options) {
|
|
13
|
-
this.models = models;
|
|
14
|
-
this.options = options;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Gets the errorsOnly value for the command, which is the inverse of the
|
|
18
|
-
* user provided verboseResults option. Defaults to true.
|
|
19
|
-
*/
|
|
20
|
-
get errorsOnly() {
|
|
21
|
-
if ('verboseResults' in this.options) {
|
|
22
|
-
return !this.options.verboseResults;
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Build the bulk write commands from the models.
|
|
28
|
-
*/
|
|
29
|
-
buildCommands() {
|
|
30
|
-
// Iterate the models to build the ops and nsInfo fields.
|
|
31
|
-
const operations = [];
|
|
32
|
-
let currentNamespaceIndex = 0;
|
|
33
|
-
const namespaces = new Map();
|
|
34
|
-
for (const model of this.models) {
|
|
35
|
-
const ns = model.namespace;
|
|
36
|
-
const index = namespaces.get(ns);
|
|
37
|
-
if (index != null) {
|
|
38
|
-
operations.push(buildOperation(model, index));
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
namespaces.set(ns, currentNamespaceIndex);
|
|
42
|
-
operations.push(buildOperation(model, currentNamespaceIndex));
|
|
43
|
-
currentNamespaceIndex++;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const nsInfo = Array.from(namespaces.keys(), ns => ({ ns }));
|
|
47
|
-
// The base command.
|
|
48
|
-
const command = {
|
|
49
|
-
bulkWrite: 1,
|
|
50
|
-
errorsOnly: this.errorsOnly,
|
|
51
|
-
ordered: this.options.ordered ?? true,
|
|
52
|
-
ops: new commands_1.DocumentSequence(operations),
|
|
53
|
-
nsInfo: new commands_1.DocumentSequence(nsInfo)
|
|
54
|
-
};
|
|
55
|
-
// Add bypassDocumentValidation if it was present in the options.
|
|
56
|
-
if (this.options.bypassDocumentValidation != null) {
|
|
57
|
-
command.bypassDocumentValidation = this.options.bypassDocumentValidation;
|
|
58
|
-
}
|
|
59
|
-
// Add let if it was present in the options.
|
|
60
|
-
if (this.options.let) {
|
|
61
|
-
command.let = this.options.let;
|
|
62
|
-
}
|
|
63
|
-
return [command];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.ClientBulkWriteCommandBuilder = ClientBulkWriteCommandBuilder;
|
|
67
|
-
/**
|
|
68
|
-
* Build the insert one operation.
|
|
69
|
-
* @param model - The insert one model.
|
|
70
|
-
* @param index - The namespace index.
|
|
71
|
-
* @returns the operation.
|
|
72
|
-
*/
|
|
73
|
-
const buildInsertOneOperation = (model, index) => {
|
|
74
|
-
const document = {
|
|
75
|
-
insert: index,
|
|
76
|
-
document: model.document
|
|
77
|
-
};
|
|
78
|
-
return document;
|
|
79
|
-
};
|
|
80
|
-
exports.buildInsertOneOperation = buildInsertOneOperation;
|
|
81
|
-
/**
|
|
82
|
-
* Build the delete one operation.
|
|
83
|
-
* @param model - The insert many model.
|
|
84
|
-
* @param index - The namespace index.
|
|
85
|
-
* @returns the operation.
|
|
86
|
-
*/
|
|
87
|
-
const buildDeleteOneOperation = (model, index) => {
|
|
88
|
-
return createDeleteOperation(model, index, false);
|
|
89
|
-
};
|
|
90
|
-
exports.buildDeleteOneOperation = buildDeleteOneOperation;
|
|
91
|
-
/**
|
|
92
|
-
* Build the delete many operation.
|
|
93
|
-
* @param model - The delete many model.
|
|
94
|
-
* @param index - The namespace index.
|
|
95
|
-
* @returns the operation.
|
|
96
|
-
*/
|
|
97
|
-
const buildDeleteManyOperation = (model, index) => {
|
|
98
|
-
return createDeleteOperation(model, index, true);
|
|
99
|
-
};
|
|
100
|
-
exports.buildDeleteManyOperation = buildDeleteManyOperation;
|
|
101
|
-
/**
|
|
102
|
-
* Creates a delete operation based on the parameters.
|
|
103
|
-
*/
|
|
104
|
-
function createDeleteOperation(model, index, multi) {
|
|
105
|
-
const document = {
|
|
106
|
-
delete: index,
|
|
107
|
-
multi: multi,
|
|
108
|
-
filter: model.filter
|
|
109
|
-
};
|
|
110
|
-
if (model.hint) {
|
|
111
|
-
document.hint = model.hint;
|
|
112
|
-
}
|
|
113
|
-
if (model.collation) {
|
|
114
|
-
document.collation = model.collation;
|
|
115
|
-
}
|
|
116
|
-
return document;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Build the update one operation.
|
|
120
|
-
* @param model - The update one model.
|
|
121
|
-
* @param index - The namespace index.
|
|
122
|
-
* @returns the operation.
|
|
123
|
-
*/
|
|
124
|
-
const buildUpdateOneOperation = (model, index) => {
|
|
125
|
-
return createUpdateOperation(model, index, false);
|
|
126
|
-
};
|
|
127
|
-
exports.buildUpdateOneOperation = buildUpdateOneOperation;
|
|
128
|
-
/**
|
|
129
|
-
* Build the update many operation.
|
|
130
|
-
* @param model - The update many model.
|
|
131
|
-
* @param index - The namespace index.
|
|
132
|
-
* @returns the operation.
|
|
133
|
-
*/
|
|
134
|
-
const buildUpdateManyOperation = (model, index) => {
|
|
135
|
-
return createUpdateOperation(model, index, true);
|
|
136
|
-
};
|
|
137
|
-
exports.buildUpdateManyOperation = buildUpdateManyOperation;
|
|
138
|
-
/**
|
|
139
|
-
* Creates a delete operation based on the parameters.
|
|
140
|
-
*/
|
|
141
|
-
function createUpdateOperation(model, index, multi) {
|
|
142
|
-
const document = {
|
|
143
|
-
update: index,
|
|
144
|
-
multi: multi,
|
|
145
|
-
filter: model.filter,
|
|
146
|
-
updateMods: model.update
|
|
147
|
-
};
|
|
148
|
-
if (model.hint) {
|
|
149
|
-
document.hint = model.hint;
|
|
150
|
-
}
|
|
151
|
-
if (model.upsert) {
|
|
152
|
-
document.upsert = model.upsert;
|
|
153
|
-
}
|
|
154
|
-
if (model.arrayFilters) {
|
|
155
|
-
document.arrayFilters = model.arrayFilters;
|
|
156
|
-
}
|
|
157
|
-
return document;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Build the replace one operation.
|
|
161
|
-
* @param model - The replace one model.
|
|
162
|
-
* @param index - The namespace index.
|
|
163
|
-
* @returns the operation.
|
|
164
|
-
*/
|
|
165
|
-
const buildReplaceOneOperation = (model, index) => {
|
|
166
|
-
const document = {
|
|
167
|
-
update: index,
|
|
168
|
-
multi: false,
|
|
169
|
-
filter: model.filter,
|
|
170
|
-
updateMods: model.replacement
|
|
171
|
-
};
|
|
172
|
-
if (model.hint) {
|
|
173
|
-
document.hint = model.hint;
|
|
174
|
-
}
|
|
175
|
-
if (model.upsert) {
|
|
176
|
-
document.upsert = model.upsert;
|
|
177
|
-
}
|
|
178
|
-
return document;
|
|
179
|
-
};
|
|
180
|
-
exports.buildReplaceOneOperation = buildReplaceOneOperation;
|
|
181
|
-
/** @internal */
|
|
182
|
-
function buildOperation(model, index) {
|
|
183
|
-
switch (model.name) {
|
|
184
|
-
case 'insertOne':
|
|
185
|
-
return (0, exports.buildInsertOneOperation)(model, index);
|
|
186
|
-
case 'deleteOne':
|
|
187
|
-
return (0, exports.buildDeleteOneOperation)(model, index);
|
|
188
|
-
case 'deleteMany':
|
|
189
|
-
return (0, exports.buildDeleteManyOperation)(model, index);
|
|
190
|
-
case 'updateOne':
|
|
191
|
-
return (0, exports.buildUpdateOneOperation)(model, index);
|
|
192
|
-
case 'updateMany':
|
|
193
|
-
return (0, exports.buildUpdateManyOperation)(model, index);
|
|
194
|
-
case 'replaceOne':
|
|
195
|
-
return (0, exports.buildReplaceOneOperation)(model, index);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
//# sourceMappingURL=command_builder.js.map
|
|
@@ -1 +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,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
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configureResourceManagement = configureResourceManagement;
|
|
4
|
-
exports.configureExplicitResourceManagement = configureExplicitResourceManagement;
|
|
5
|
-
/** @internal */
|
|
6
|
-
function configureResourceManagement(target) {
|
|
7
|
-
Symbol.asyncDispose &&
|
|
8
|
-
Object.defineProperty(target, Symbol.asyncDispose, {
|
|
9
|
-
value: async function asyncDispose() {
|
|
10
|
-
await this.asyncDispose();
|
|
11
|
-
},
|
|
12
|
-
enumerable: false,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @beta
|
|
19
|
-
* @experimental
|
|
20
|
-
*
|
|
21
|
-
* Attaches `Symbol.asyncDispose` methods to the MongoClient, Cursors, sessions and change streams
|
|
22
|
-
* if Symbol.asyncDispose is defined.
|
|
23
|
-
*
|
|
24
|
-
* It's usually not necessary to call this method - the driver attempts to attach these methods
|
|
25
|
-
* itself when its loaded. However, sometimes the driver may be loaded before `Symbol.asyncDispose`
|
|
26
|
-
* is defined, in which case it is necessary to call this method directly. This can happen if the
|
|
27
|
-
* application is polyfilling `Symbol.asyncDispose`.
|
|
28
|
-
*
|
|
29
|
-
* Example:
|
|
30
|
-
*
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { configureExplicitResourceManagement, MongoClient } from 'mongodb/lib/beta';
|
|
33
|
-
*
|
|
34
|
-
* Symbol.asyncDispose ??= Symbol('dispose');
|
|
35
|
-
* load();
|
|
36
|
-
*
|
|
37
|
-
* await using client = new MongoClient(...);
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
function configureExplicitResourceManagement() {
|
|
41
|
-
// We must import lazily here, because there's a circular dependency between the resource management
|
|
42
|
-
// file and each resources' file. We could move `configureResourceManagement` to a separate
|
|
43
|
-
// function, but keeping all resource-management related code together seemed preferable and I chose
|
|
44
|
-
// lazy requiring of resources instead.
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
46
|
-
const { MongoClient } = require('./mongo_client');
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
48
|
-
const { ClientSession } = require('./sessions');
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
50
|
-
const { AbstractCursor } = require('./cursor/abstract_cursor');
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
52
|
-
const { ChangeStream } = require('./change_stream');
|
|
53
|
-
configureResourceManagement(MongoClient.prototype);
|
|
54
|
-
configureResourceManagement(ClientSession.prototype);
|
|
55
|
-
configureResourceManagement(AbstractCursor.prototype);
|
|
56
|
-
configureResourceManagement(ChangeStream.prototype);
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=resource_management.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource_management.js","sourceRoot":"","sources":["../src/resource_management.ts"],"names":[],"mappings":";;AAmBA,kEAUC;AAyBD,kFAmBC;AAvDD,gBAAgB;AAChB,SAAgB,2BAA2B,CAAC,MAAuB;IACjE,MAAM,CAAC,YAAY;QACjB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE;YACjD,KAAK,EAAE,KAAK,UAAU,YAAY;gBAChC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5B,CAAC;YACD,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,mCAAmC;IACjD,oGAAoG;IACpG,4FAA4F;IAC5F,oGAAoG;IACpG,uCAAuC;IAEvC,iEAAiE;IACjE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAClD,iEAAiE;IACjE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAChD,iEAAiE;IACjE,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC/D,iEAAiE;IACjE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEpD,2BAA2B,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACnD,2BAA2B,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACrD,2BAA2B,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACtD,2BAA2B,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACtD,CAAC"}
|
package/src/beta.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type Document } from 'bson';
|
|
2
|
-
|
|
3
|
-
export * from './index';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*
|
|
8
|
-
* Since we don't bundle tslib helpers, we need to polyfill this method.
|
|
9
|
-
*
|
|
10
|
-
* This is used in the generated JS. Adapted from https://github.com/microsoft/TypeScript/blob/aafdfe5b3f76f5c41abeec412ce73c86da94c75f/src/compiler/factory/emitHelpers.ts#L1202.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
function __exportStar(mod: Document) {
|
|
14
|
-
for (const key of Object.keys(mod)) {
|
|
15
|
-
Object.defineProperty(exports, key, {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () {
|
|
18
|
-
return mod[key];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { type Document } from '../../bson';
|
|
2
|
-
import { DocumentSequence } from '../../cmap/commands';
|
|
3
|
-
import type { Filter, OptionalId, UpdateFilter, WithoutId } from '../../mongo_types';
|
|
4
|
-
import { type CollationOptions } from '../command';
|
|
5
|
-
import { type Hint } from '../operation';
|
|
6
|
-
import type {
|
|
7
|
-
AnyClientBulkWriteModel,
|
|
8
|
-
ClientBulkWriteOptions,
|
|
9
|
-
ClientDeleteManyModel,
|
|
10
|
-
ClientDeleteOneModel,
|
|
11
|
-
ClientInsertOneModel,
|
|
12
|
-
ClientReplaceOneModel,
|
|
13
|
-
ClientUpdateManyModel,
|
|
14
|
-
ClientUpdateOneModel
|
|
15
|
-
} from './common';
|
|
16
|
-
|
|
17
|
-
/** @internal */
|
|
18
|
-
export interface ClientBulkWriteCommand {
|
|
19
|
-
bulkWrite: 1;
|
|
20
|
-
errorsOnly: boolean;
|
|
21
|
-
ordered: boolean;
|
|
22
|
-
ops: DocumentSequence;
|
|
23
|
-
nsInfo: DocumentSequence;
|
|
24
|
-
bypassDocumentValidation?: boolean;
|
|
25
|
-
let?: Document;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** @internal */
|
|
29
|
-
export class ClientBulkWriteCommandBuilder {
|
|
30
|
-
models: AnyClientBulkWriteModel[];
|
|
31
|
-
options: ClientBulkWriteOptions;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Create the command builder.
|
|
35
|
-
* @param models - The client write models.
|
|
36
|
-
*/
|
|
37
|
-
constructor(models: AnyClientBulkWriteModel[], options: ClientBulkWriteOptions) {
|
|
38
|
-
this.models = models;
|
|
39
|
-
this.options = options;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Gets the errorsOnly value for the command, which is the inverse of the
|
|
44
|
-
* user provided verboseResults option. Defaults to true.
|
|
45
|
-
*/
|
|
46
|
-
get errorsOnly(): boolean {
|
|
47
|
-
if ('verboseResults' in this.options) {
|
|
48
|
-
return !this.options.verboseResults;
|
|
49
|
-
}
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Build the bulk write commands from the models.
|
|
55
|
-
*/
|
|
56
|
-
buildCommands(): ClientBulkWriteCommand[] {
|
|
57
|
-
// Iterate the models to build the ops and nsInfo fields.
|
|
58
|
-
const operations = [];
|
|
59
|
-
let currentNamespaceIndex = 0;
|
|
60
|
-
const namespaces = new Map<string, number>();
|
|
61
|
-
for (const model of this.models) {
|
|
62
|
-
const ns = model.namespace;
|
|
63
|
-
const index = namespaces.get(ns);
|
|
64
|
-
if (index != null) {
|
|
65
|
-
operations.push(buildOperation(model, index));
|
|
66
|
-
} else {
|
|
67
|
-
namespaces.set(ns, currentNamespaceIndex);
|
|
68
|
-
operations.push(buildOperation(model, currentNamespaceIndex));
|
|
69
|
-
currentNamespaceIndex++;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const nsInfo = Array.from(namespaces.keys(), ns => ({ ns }));
|
|
74
|
-
|
|
75
|
-
// The base command.
|
|
76
|
-
const command: ClientBulkWriteCommand = {
|
|
77
|
-
bulkWrite: 1,
|
|
78
|
-
errorsOnly: this.errorsOnly,
|
|
79
|
-
ordered: this.options.ordered ?? true,
|
|
80
|
-
ops: new DocumentSequence(operations),
|
|
81
|
-
nsInfo: new DocumentSequence(nsInfo)
|
|
82
|
-
};
|
|
83
|
-
// Add bypassDocumentValidation if it was present in the options.
|
|
84
|
-
if (this.options.bypassDocumentValidation != null) {
|
|
85
|
-
command.bypassDocumentValidation = this.options.bypassDocumentValidation;
|
|
86
|
-
}
|
|
87
|
-
// Add let if it was present in the options.
|
|
88
|
-
if (this.options.let) {
|
|
89
|
-
command.let = this.options.let;
|
|
90
|
-
}
|
|
91
|
-
return [command];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** @internal */
|
|
96
|
-
interface ClientInsertOperation {
|
|
97
|
-
insert: number;
|
|
98
|
-
document: OptionalId<Document>;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Build the insert one operation.
|
|
103
|
-
* @param model - The insert one model.
|
|
104
|
-
* @param index - The namespace index.
|
|
105
|
-
* @returns the operation.
|
|
106
|
-
*/
|
|
107
|
-
export const buildInsertOneOperation = (
|
|
108
|
-
model: ClientInsertOneModel,
|
|
109
|
-
index: number
|
|
110
|
-
): ClientInsertOperation => {
|
|
111
|
-
const document: ClientInsertOperation = {
|
|
112
|
-
insert: index,
|
|
113
|
-
document: model.document
|
|
114
|
-
};
|
|
115
|
-
return document;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/** @internal */
|
|
119
|
-
export interface ClientDeleteOperation {
|
|
120
|
-
delete: number;
|
|
121
|
-
multi: boolean;
|
|
122
|
-
filter: Filter<Document>;
|
|
123
|
-
hint?: Hint;
|
|
124
|
-
collation?: CollationOptions;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Build the delete one operation.
|
|
129
|
-
* @param model - The insert many model.
|
|
130
|
-
* @param index - The namespace index.
|
|
131
|
-
* @returns the operation.
|
|
132
|
-
*/
|
|
133
|
-
export const buildDeleteOneOperation = (model: ClientDeleteOneModel, index: number): Document => {
|
|
134
|
-
return createDeleteOperation(model, index, false);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Build the delete many operation.
|
|
139
|
-
* @param model - The delete many model.
|
|
140
|
-
* @param index - The namespace index.
|
|
141
|
-
* @returns the operation.
|
|
142
|
-
*/
|
|
143
|
-
export const buildDeleteManyOperation = (model: ClientDeleteManyModel, index: number): Document => {
|
|
144
|
-
return createDeleteOperation(model, index, true);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Creates a delete operation based on the parameters.
|
|
149
|
-
*/
|
|
150
|
-
function createDeleteOperation(
|
|
151
|
-
model: ClientDeleteOneModel | ClientDeleteManyModel,
|
|
152
|
-
index: number,
|
|
153
|
-
multi: boolean
|
|
154
|
-
): ClientDeleteOperation {
|
|
155
|
-
const document: ClientDeleteOperation = {
|
|
156
|
-
delete: index,
|
|
157
|
-
multi: multi,
|
|
158
|
-
filter: model.filter
|
|
159
|
-
};
|
|
160
|
-
if (model.hint) {
|
|
161
|
-
document.hint = model.hint;
|
|
162
|
-
}
|
|
163
|
-
if (model.collation) {
|
|
164
|
-
document.collation = model.collation;
|
|
165
|
-
}
|
|
166
|
-
return document;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** @internal */
|
|
170
|
-
export interface ClientUpdateOperation {
|
|
171
|
-
update: number;
|
|
172
|
-
multi: boolean;
|
|
173
|
-
filter: Filter<Document>;
|
|
174
|
-
updateMods: UpdateFilter<Document> | Document[];
|
|
175
|
-
hint?: Hint;
|
|
176
|
-
upsert?: boolean;
|
|
177
|
-
arrayFilters?: Document[];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Build the update one operation.
|
|
182
|
-
* @param model - The update one model.
|
|
183
|
-
* @param index - The namespace index.
|
|
184
|
-
* @returns the operation.
|
|
185
|
-
*/
|
|
186
|
-
export const buildUpdateOneOperation = (
|
|
187
|
-
model: ClientUpdateOneModel,
|
|
188
|
-
index: number
|
|
189
|
-
): ClientUpdateOperation => {
|
|
190
|
-
return createUpdateOperation(model, index, false);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Build the update many operation.
|
|
195
|
-
* @param model - The update many model.
|
|
196
|
-
* @param index - The namespace index.
|
|
197
|
-
* @returns the operation.
|
|
198
|
-
*/
|
|
199
|
-
export const buildUpdateManyOperation = (
|
|
200
|
-
model: ClientUpdateManyModel,
|
|
201
|
-
index: number
|
|
202
|
-
): ClientUpdateOperation => {
|
|
203
|
-
return createUpdateOperation(model, index, true);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Creates a delete operation based on the parameters.
|
|
208
|
-
*/
|
|
209
|
-
function createUpdateOperation(
|
|
210
|
-
model: ClientUpdateOneModel | ClientUpdateManyModel,
|
|
211
|
-
index: number,
|
|
212
|
-
multi: boolean
|
|
213
|
-
): ClientUpdateOperation {
|
|
214
|
-
const document: ClientUpdateOperation = {
|
|
215
|
-
update: index,
|
|
216
|
-
multi: multi,
|
|
217
|
-
filter: model.filter,
|
|
218
|
-
updateMods: model.update
|
|
219
|
-
};
|
|
220
|
-
if (model.hint) {
|
|
221
|
-
document.hint = model.hint;
|
|
222
|
-
}
|
|
223
|
-
if (model.upsert) {
|
|
224
|
-
document.upsert = model.upsert;
|
|
225
|
-
}
|
|
226
|
-
if (model.arrayFilters) {
|
|
227
|
-
document.arrayFilters = model.arrayFilters;
|
|
228
|
-
}
|
|
229
|
-
return document;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/** @internal */
|
|
233
|
-
export interface ClientReplaceOneOperation {
|
|
234
|
-
update: number;
|
|
235
|
-
multi: boolean;
|
|
236
|
-
filter: Filter<Document>;
|
|
237
|
-
updateMods: WithoutId<Document>;
|
|
238
|
-
hint?: Hint;
|
|
239
|
-
upsert?: boolean;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Build the replace one operation.
|
|
244
|
-
* @param model - The replace one model.
|
|
245
|
-
* @param index - The namespace index.
|
|
246
|
-
* @returns the operation.
|
|
247
|
-
*/
|
|
248
|
-
export const buildReplaceOneOperation = (
|
|
249
|
-
model: ClientReplaceOneModel,
|
|
250
|
-
index: number
|
|
251
|
-
): ClientReplaceOneOperation => {
|
|
252
|
-
const document: ClientReplaceOneOperation = {
|
|
253
|
-
update: index,
|
|
254
|
-
multi: false,
|
|
255
|
-
filter: model.filter,
|
|
256
|
-
updateMods: model.replacement
|
|
257
|
-
};
|
|
258
|
-
if (model.hint) {
|
|
259
|
-
document.hint = model.hint;
|
|
260
|
-
}
|
|
261
|
-
if (model.upsert) {
|
|
262
|
-
document.upsert = model.upsert;
|
|
263
|
-
}
|
|
264
|
-
return document;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
/** @internal */
|
|
268
|
-
export function buildOperation(model: AnyClientBulkWriteModel, index: number): Document {
|
|
269
|
-
switch (model.name) {
|
|
270
|
-
case 'insertOne':
|
|
271
|
-
return buildInsertOneOperation(model, index);
|
|
272
|
-
case 'deleteOne':
|
|
273
|
-
return buildDeleteOneOperation(model, index);
|
|
274
|
-
case 'deleteMany':
|
|
275
|
-
return buildDeleteManyOperation(model, index);
|
|
276
|
-
case 'updateOne':
|
|
277
|
-
return buildUpdateOneOperation(model, index);
|
|
278
|
-
case 'updateMany':
|
|
279
|
-
return buildUpdateManyOperation(model, index);
|
|
280
|
-
case 'replaceOne':
|
|
281
|
-
return buildReplaceOneOperation(model, index);
|
|
282
|
-
}
|
|
283
|
-
}
|