mongodb 6.18.0 → 6.19.0-dev.20250828.sha.41034f16
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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FindOneAndUpdateOperation = exports.FindOneAndReplaceOperation = exports.FindOneAndDeleteOperation = exports.FindAndModifyOperation = exports.ReturnDocument = void 0;
|
|
4
|
+
const responses_1 = require("../cmap/wire_protocol/responses");
|
|
4
5
|
const error_1 = require("../error");
|
|
5
6
|
const read_preference_1 = require("../read_preference");
|
|
6
7
|
const sort_1 = require("../sort");
|
|
@@ -24,8 +25,21 @@ function configureFindAndModifyCmdBaseUpdateOpts(cmdBase, options) {
|
|
|
24
25
|
class FindAndModifyOperation extends command_1.CommandOperation {
|
|
25
26
|
constructor(collection, query, options) {
|
|
26
27
|
super(collection, options);
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
28
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
|
29
|
+
this.options = options;
|
|
30
|
+
// force primary read preference
|
|
31
|
+
this.readPreference = read_preference_1.ReadPreference.primary;
|
|
32
|
+
this.collection = collection;
|
|
33
|
+
this.query = query;
|
|
34
|
+
}
|
|
35
|
+
get commandName() {
|
|
36
|
+
return 'findAndModify';
|
|
37
|
+
}
|
|
38
|
+
buildCommandDocument(_connection, _session) {
|
|
39
|
+
const options = this.options;
|
|
40
|
+
const command = {
|
|
41
|
+
findAndModify: this.collection.collectionName,
|
|
42
|
+
query: this.query,
|
|
29
43
|
remove: false,
|
|
30
44
|
new: false,
|
|
31
45
|
upsert: false
|
|
@@ -33,57 +47,39 @@ class FindAndModifyOperation extends command_1.CommandOperation {
|
|
|
33
47
|
options.includeResultMetadata ??= false;
|
|
34
48
|
const sort = (0, sort_1.formatSort)(options.sort);
|
|
35
49
|
if (sort) {
|
|
36
|
-
|
|
50
|
+
command.sort = sort;
|
|
37
51
|
}
|
|
38
52
|
if (options.projection) {
|
|
39
|
-
|
|
53
|
+
command.fields = options.projection;
|
|
40
54
|
}
|
|
41
55
|
if (options.maxTimeMS) {
|
|
42
|
-
|
|
56
|
+
command.maxTimeMS = options.maxTimeMS;
|
|
43
57
|
}
|
|
44
58
|
// Decorate the findAndModify command with the write Concern
|
|
45
59
|
if (options.writeConcern) {
|
|
46
|
-
|
|
60
|
+
command.writeConcern = options.writeConcern;
|
|
47
61
|
}
|
|
48
62
|
if (options.let) {
|
|
49
|
-
|
|
63
|
+
command.let = options.let;
|
|
50
64
|
}
|
|
51
65
|
// we check for undefined specifically here to allow falsy values
|
|
52
66
|
// eslint-disable-next-line no-restricted-syntax
|
|
53
67
|
if (options.comment !== undefined) {
|
|
54
|
-
|
|
68
|
+
command.comment = options.comment;
|
|
55
69
|
}
|
|
56
|
-
|
|
57
|
-
this.readPreference = read_preference_1.ReadPreference.primary;
|
|
58
|
-
this.collection = collection;
|
|
59
|
-
this.query = query;
|
|
60
|
-
}
|
|
61
|
-
get commandName() {
|
|
62
|
-
return 'findAndModify';
|
|
63
|
-
}
|
|
64
|
-
async execute(server, session, timeoutContext) {
|
|
65
|
-
const coll = this.collection;
|
|
66
|
-
const query = this.query;
|
|
67
|
-
const options = { ...this.options, ...this.bsonOptions };
|
|
68
|
-
// Create findAndModify command object
|
|
69
|
-
const cmd = {
|
|
70
|
-
findAndModify: coll.collectionName,
|
|
71
|
-
query: query,
|
|
72
|
-
...this.cmdBase
|
|
73
|
-
};
|
|
74
|
-
(0, utils_1.decorateWithCollation)(cmd, coll, options);
|
|
70
|
+
(0, utils_1.decorateWithCollation)(command, this.collection, options);
|
|
75
71
|
if (options.hint) {
|
|
76
|
-
// TODO: once this method becomes a CommandOperation we will have the server
|
|
77
|
-
// in place to check.
|
|
78
72
|
const unacknowledgedWrite = this.writeConcern?.w === 0;
|
|
79
|
-
if (unacknowledgedWrite
|
|
73
|
+
if (unacknowledgedWrite) {
|
|
80
74
|
throw new error_1.MongoCompatibilityError('The current topology does not support a hint on findAndModify commands');
|
|
81
75
|
}
|
|
82
|
-
|
|
76
|
+
command.hint = options.hint;
|
|
83
77
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
return command;
|
|
79
|
+
}
|
|
80
|
+
handleOk(response) {
|
|
81
|
+
const result = super.handleOk(response);
|
|
82
|
+
return this.options.includeResultMetadata ? result : (result.value ?? null);
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
exports.FindAndModifyOperation = FindAndModifyOperation;
|
|
@@ -95,7 +91,11 @@ class FindOneAndDeleteOperation extends FindAndModifyOperation {
|
|
|
95
91
|
throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
|
|
96
92
|
}
|
|
97
93
|
super(collection, filter, options);
|
|
98
|
-
|
|
94
|
+
}
|
|
95
|
+
buildCommandDocument(connection, session) {
|
|
96
|
+
const document = super.buildCommandDocument(connection, session);
|
|
97
|
+
document.remove = true;
|
|
98
|
+
return document;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
exports.FindOneAndDeleteOperation = FindOneAndDeleteOperation;
|
|
@@ -112,8 +112,13 @@ class FindOneAndReplaceOperation extends FindAndModifyOperation {
|
|
|
112
112
|
throw new error_1.MongoInvalidArgumentError('Replacement document must not contain atomic operators');
|
|
113
113
|
}
|
|
114
114
|
super(collection, filter, options);
|
|
115
|
-
this.
|
|
116
|
-
|
|
115
|
+
this.replacement = replacement;
|
|
116
|
+
}
|
|
117
|
+
buildCommandDocument(connection, session) {
|
|
118
|
+
const document = super.buildCommandDocument(connection, session);
|
|
119
|
+
document.update = this.replacement;
|
|
120
|
+
configureFindAndModifyCmdBaseUpdateOpts(document, this.options);
|
|
121
|
+
return document;
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
exports.FindOneAndReplaceOperation = FindOneAndReplaceOperation;
|
|
@@ -130,11 +135,17 @@ class FindOneAndUpdateOperation extends FindAndModifyOperation {
|
|
|
130
135
|
throw new error_1.MongoInvalidArgumentError('Update document requires atomic operators');
|
|
131
136
|
}
|
|
132
137
|
super(collection, filter, options);
|
|
133
|
-
this.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
this.update = update;
|
|
139
|
+
this.options = options;
|
|
140
|
+
}
|
|
141
|
+
buildCommandDocument(connection, session) {
|
|
142
|
+
const document = super.buildCommandDocument(connection, session);
|
|
143
|
+
document.update = this.update;
|
|
144
|
+
configureFindAndModifyCmdBaseUpdateOpts(document, this.options);
|
|
145
|
+
if (this.options.arrayFilters) {
|
|
146
|
+
document.arrayFilters = this.options.arrayFilters;
|
|
137
147
|
}
|
|
148
|
+
return document;
|
|
138
149
|
}
|
|
139
150
|
}
|
|
140
151
|
exports.FindOneAndUpdateOperation = FindOneAndUpdateOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find_and_modify.js","sourceRoot":"","sources":["../../src/operations/find_and_modify.ts"],"names":[],"mappings":";;;AAEA,oCAA8E;AAC9E,wDAAoD;
|
|
1
|
+
{"version":3,"file":"find_and_modify.js","sourceRoot":"","sources":["../../src/operations/find_and_modify.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAElE,oCAA8E;AAC9E,wDAAoD;AAEpD,kCAAiE;AACjE,oCAAqE;AAErE,uCAA2E;AAC3E,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AAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACjE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,uCAAuC,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEhE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC9B,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QACpD,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAzCD,8DAyCC;AAED,IAAA,yBAAa,EAAC,sBAAsB,EAAE;IACpC,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,WAAW;CACnB,CAAC,CAAC"}
|
|
@@ -9,6 +9,7 @@ const operation_1 = require("./operation");
|
|
|
9
9
|
class GetMoreOperation extends operation_1.AbstractOperation {
|
|
10
10
|
constructor(ns, cursorId, server, options) {
|
|
11
11
|
super(options);
|
|
12
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
|
12
13
|
this.options = options;
|
|
13
14
|
this.ns = ns;
|
|
14
15
|
this.cursorId = cursorId;
|
|
@@ -17,14 +18,7 @@ class GetMoreOperation extends operation_1.AbstractOperation {
|
|
|
17
18
|
get commandName() {
|
|
18
19
|
return 'getMore';
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
* Although there is a server already associated with the get more operation, the signature
|
|
22
|
-
* for execute passes a server so we will just use that one.
|
|
23
|
-
*/
|
|
24
|
-
async execute(server, _session, timeoutContext) {
|
|
25
|
-
if (server !== this.server) {
|
|
26
|
-
throw new error_1.MongoRuntimeError('Getmore must run on the same server operation began on');
|
|
27
|
-
}
|
|
21
|
+
buildCommand(connection) {
|
|
28
22
|
if (this.cursorId == null || this.cursorId.isZero()) {
|
|
29
23
|
throw new error_1.MongoRuntimeError('Unable to iterate cursor with no id');
|
|
30
24
|
}
|
|
@@ -46,16 +40,21 @@ class GetMoreOperation extends operation_1.AbstractOperation {
|
|
|
46
40
|
}
|
|
47
41
|
// we check for undefined specifically here to allow falsy values
|
|
48
42
|
// eslint-disable-next-line no-restricted-syntax
|
|
49
|
-
if (this.options.comment !== undefined && (0, utils_1.maxWireVersion)(
|
|
43
|
+
if (this.options.comment !== undefined && (0, utils_1.maxWireVersion)(connection) >= 9) {
|
|
50
44
|
getMoreCmd.comment = this.options.comment;
|
|
51
45
|
}
|
|
52
|
-
|
|
46
|
+
return getMoreCmd;
|
|
47
|
+
}
|
|
48
|
+
buildOptions(timeoutContext) {
|
|
49
|
+
return {
|
|
53
50
|
returnFieldSelector: null,
|
|
54
51
|
documentsReturnedIn: 'nextBatch',
|
|
55
52
|
timeoutContext,
|
|
56
53
|
...this.options
|
|
57
54
|
};
|
|
58
|
-
|
|
55
|
+
}
|
|
56
|
+
handleOk(response) {
|
|
57
|
+
return response;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
exports.GetMoreOperation = GetMoreOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_more.js","sourceRoot":"","sources":["../../src/operations/get_more.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"get_more.js","sourceRoot":"","sources":["../../src/operations/get_more.ts"],"names":[],"mappings":";;;AAEA,+DAAiE;AACjE,oCAA6C;AAG7C,oCAAiE;AACjE,2CAA8F;AA+B9F,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,6BAAiC;IAKrE,YAAY,EAAoB,EAAE,QAAc,EAAE,MAAc,EAAE,OAAuB;QACvF,KAAK,CAAC,OAAO,CAAC,CAAC;QALR,iCAA4B,GAAG,0BAAc,CAAC;QAOrD,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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,GAAG,IAAI,CAAC,OAAO;SAChB,CAAC;IACJ,CAAC;IAEQ,QAAQ,CACf,QAAgE;QAEhE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlED,4CAkEC;AAED,IAAA,yBAAa,EAAC,gBAAgB,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC"}
|
|
@@ -81,7 +81,10 @@ function resolveIndexDescription(description) {
|
|
|
81
81
|
class CreateIndexesOperation extends command_1.CommandOperation {
|
|
82
82
|
constructor(parent, collectionName, indexes, options) {
|
|
83
83
|
super(parent, options);
|
|
84
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
|
84
85
|
this.options = options ?? {};
|
|
86
|
+
// collation is set on each index, it should not be defined at the root
|
|
87
|
+
this.options.collation = undefined;
|
|
85
88
|
this.collectionName = collectionName;
|
|
86
89
|
this.indexes = indexes.map((userIndex) => {
|
|
87
90
|
// Ensure the key is a Map to preserve index key ordering
|
|
@@ -94,6 +97,7 @@ class CreateIndexesOperation extends command_1.CommandOperation {
|
|
|
94
97
|
key
|
|
95
98
|
};
|
|
96
99
|
});
|
|
100
|
+
this.ns = parent.s.namespace;
|
|
97
101
|
}
|
|
98
102
|
static fromIndexDescriptionArray(parent, collectionName, indexes, options) {
|
|
99
103
|
return new CreateIndexesOperation(parent, collectionName, indexes, options);
|
|
@@ -106,10 +110,10 @@ class CreateIndexesOperation extends command_1.CommandOperation {
|
|
|
106
110
|
get commandName() {
|
|
107
111
|
return 'createIndexes';
|
|
108
112
|
}
|
|
109
|
-
|
|
113
|
+
buildCommandDocument(connection) {
|
|
110
114
|
const options = this.options;
|
|
111
115
|
const indexes = this.indexes;
|
|
112
|
-
const serverWireVersion = (0, utils_1.maxWireVersion)(
|
|
116
|
+
const serverWireVersion = (0, utils_1.maxWireVersion)(connection);
|
|
113
117
|
const cmd = { createIndexes: this.collectionName, indexes };
|
|
114
118
|
if (options.commitQuorum != null) {
|
|
115
119
|
if (serverWireVersion < 9) {
|
|
@@ -117,10 +121,10 @@ class CreateIndexesOperation extends command_1.CommandOperation {
|
|
|
117
121
|
}
|
|
118
122
|
cmd.commitQuorum = options.commitQuorum;
|
|
119
123
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const indexNames = indexes.map(index => index.name || '');
|
|
124
|
+
return cmd;
|
|
125
|
+
}
|
|
126
|
+
handleOk(_response) {
|
|
127
|
+
const indexNames = this.indexes.map(index => index.name || '');
|
|
124
128
|
return indexNames;
|
|
125
129
|
}
|
|
126
130
|
}
|
|
@@ -129,16 +133,17 @@ exports.CreateIndexesOperation = CreateIndexesOperation;
|
|
|
129
133
|
class DropIndexOperation extends command_1.CommandOperation {
|
|
130
134
|
constructor(collection, indexName, options) {
|
|
131
135
|
super(collection, options);
|
|
136
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
|
132
137
|
this.options = options ?? {};
|
|
133
138
|
this.collection = collection;
|
|
134
139
|
this.indexName = indexName;
|
|
140
|
+
this.ns = collection.fullNamespace;
|
|
135
141
|
}
|
|
136
142
|
get commandName() {
|
|
137
143
|
return 'dropIndexes';
|
|
138
144
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return await super.executeCommand(server, session, cmd, timeoutContext);
|
|
145
|
+
buildCommandDocument(_connection) {
|
|
146
|
+
return { dropIndexes: this.collection.collectionName, index: this.indexName };
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
149
|
exports.DropIndexOperation = DropIndexOperation;
|
|
@@ -146,6 +151,7 @@ exports.DropIndexOperation = DropIndexOperation;
|
|
|
146
151
|
class ListIndexesOperation extends command_1.CommandOperation {
|
|
147
152
|
constructor(collection, options) {
|
|
148
153
|
super(collection, options);
|
|
154
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
|
149
155
|
this.options = { ...options };
|
|
150
156
|
delete this.options.writeConcern;
|
|
151
157
|
this.collectionNamespace = collection.s.namespace;
|
|
@@ -153,8 +159,8 @@ class ListIndexesOperation extends command_1.CommandOperation {
|
|
|
153
159
|
get commandName() {
|
|
154
160
|
return 'listIndexes';
|
|
155
161
|
}
|
|
156
|
-
|
|
157
|
-
const serverWireVersion = (0, utils_1.maxWireVersion)(
|
|
162
|
+
buildCommandDocument(connection) {
|
|
163
|
+
const serverWireVersion = (0, utils_1.maxWireVersion)(connection);
|
|
158
164
|
const cursor = this.options.batchSize ? { batchSize: this.options.batchSize } : {};
|
|
159
165
|
const command = { listIndexes: this.collectionNamespace.collection, cursor };
|
|
160
166
|
// we check for undefined specifically here to allow falsy values
|
|
@@ -162,7 +168,10 @@ class ListIndexesOperation extends command_1.CommandOperation {
|
|
|
162
168
|
if (serverWireVersion >= 9 && this.options.comment !== undefined) {
|
|
163
169
|
command.comment = this.options.comment;
|
|
164
170
|
}
|
|
165
|
-
return
|
|
171
|
+
return command;
|
|
172
|
+
}
|
|
173
|
+
handleOk(response) {
|
|
174
|
+
return response;
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
exports.ListIndexesOperation = ListIndexesOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexes.js","sourceRoot":"","sources":["../../src/operations/indexes.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"indexes.js","sourceRoot":"","sources":["../../src/operations/indexes.ts"],"names":[],"mappings":";;;AAEA,+DAAkF;AAGlF,oCAAmD;AAEnD,oCAA2E;AAC3E,uCAKmB;AACnB,2CAAoD;AAEpD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,yBAAyB;IACzB,QAAQ;IACR,QAAQ;IACR,oBAAoB;IACpB,eAAe;IACf,WAAW;IACX,SAAS;IAET,eAAe;IACf,SAAS;IACT,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAElB,oBAAoB;IACpB,s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D,oDA6CC;AAED,IAAA,yBAAa,EAAC,oBAAoB,EAAE;IAClC,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;CACvB,CAAC,CAAC;AACH,IAAA,yBAAa,EAAC,sBAAsB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AAChE,IAAA,yBAAa,EAAC,kBAAkB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
package/lib/operations/insert.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InsertOneOperation = exports.InsertOperation = void 0;
|
|
4
|
+
const responses_1 = require("../cmap/wire_protocol/responses");
|
|
4
5
|
const error_1 = require("../error");
|
|
5
6
|
const utils_1 = require("../utils");
|
|
6
|
-
const write_concern_1 = require("../write_concern");
|
|
7
|
-
const bulk_write_1 = require("./bulk_write");
|
|
8
7
|
const command_1 = require("./command");
|
|
9
8
|
const operation_1 = require("./operation");
|
|
10
9
|
/** @internal */
|
|
11
10
|
class InsertOperation extends command_1.CommandOperation {
|
|
12
11
|
constructor(ns, documents, options) {
|
|
13
12
|
super(undefined, options);
|
|
13
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
|
14
14
|
this.options = { ...options, checkKeys: options.checkKeys ?? false };
|
|
15
15
|
this.ns = ns;
|
|
16
16
|
this.documents = documents;
|
|
@@ -18,7 +18,7 @@ class InsertOperation extends command_1.CommandOperation {
|
|
|
18
18
|
get commandName() {
|
|
19
19
|
return 'insert';
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
buildCommandDocument(_connection, _session) {
|
|
22
22
|
const options = this.options ?? {};
|
|
23
23
|
const ordered = typeof options.ordered === 'boolean' ? options.ordered : true;
|
|
24
24
|
const command = {
|
|
@@ -34,16 +34,16 @@ class InsertOperation extends command_1.CommandOperation {
|
|
|
34
34
|
if (options.comment !== undefined) {
|
|
35
35
|
command.comment = options.comment;
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return command;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.InsertOperation = InsertOperation;
|
|
41
41
|
class InsertOneOperation extends InsertOperation {
|
|
42
42
|
constructor(collection, doc, options) {
|
|
43
|
-
super(collection.s.namespace, (0, utils_1.maybeAddIdToDocuments)(collection,
|
|
43
|
+
super(collection.s.namespace, [(0, utils_1.maybeAddIdToDocuments)(collection, doc, options)], options);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
const res =
|
|
45
|
+
handleOk(response) {
|
|
46
|
+
const res = super.handleOk(response);
|
|
47
47
|
if (res.code)
|
|
48
48
|
throw new error_1.MongoServerError(res);
|
|
49
49
|
if (res.writeErrors) {
|
|
@@ -57,45 +57,6 @@ class InsertOneOperation extends InsertOperation {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
exports.InsertOneOperation = InsertOneOperation;
|
|
60
|
-
/** @internal */
|
|
61
|
-
class InsertManyOperation extends operation_1.AbstractOperation {
|
|
62
|
-
constructor(collection, docs, options) {
|
|
63
|
-
super(options);
|
|
64
|
-
if (!Array.isArray(docs)) {
|
|
65
|
-
throw new error_1.MongoInvalidArgumentError('Argument "docs" must be an array of documents');
|
|
66
|
-
}
|
|
67
|
-
this.options = options;
|
|
68
|
-
this.collection = collection;
|
|
69
|
-
this.docs = docs;
|
|
70
|
-
}
|
|
71
|
-
get commandName() {
|
|
72
|
-
return 'insert';
|
|
73
|
-
}
|
|
74
|
-
async execute(server, session, timeoutContext) {
|
|
75
|
-
const coll = this.collection;
|
|
76
|
-
const options = { ...this.options, ...this.bsonOptions, readPreference: this.readPreference };
|
|
77
|
-
const writeConcern = write_concern_1.WriteConcern.fromOptions(options);
|
|
78
|
-
const bulkWriteOperation = new bulk_write_1.BulkWriteOperation(coll, this.docs.map(document => ({
|
|
79
|
-
insertOne: { document }
|
|
80
|
-
})), options);
|
|
81
|
-
try {
|
|
82
|
-
const res = await bulkWriteOperation.execute(server, session, timeoutContext);
|
|
83
|
-
return {
|
|
84
|
-
acknowledged: writeConcern?.w !== 0,
|
|
85
|
-
insertedCount: res.insertedCount,
|
|
86
|
-
insertedIds: res.insertedIds
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
if (err && err.message === 'Operation must be an object with an operation key') {
|
|
91
|
-
throw new error_1.MongoInvalidArgumentError('Collection.insertMany() cannot be called with an array that has null/undefined values');
|
|
92
|
-
}
|
|
93
|
-
throw err;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.InsertManyOperation = InsertManyOperation;
|
|
98
60
|
(0, operation_1.defineAspects)(InsertOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION]);
|
|
99
61
|
(0, operation_1.defineAspects)(InsertOneOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION]);
|
|
100
|
-
(0, operation_1.defineAspects)(InsertManyOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
|
101
62
|
//# sourceMappingURL=insert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.js","sourceRoot":"","sources":["../../src/operations/insert.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"insert.js","sourceRoot":"","sources":["../../src/operations/insert.ts"],"names":[],"mappings":";;;AAGA,+DAAkE;AAElE,oCAA4C;AAG5C,oCAAwE;AACxE,uCAA2E;AAC3E,2CAAoD;AACpD,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,0BAA0B;IAM7D,YAAY,EAAoB,EAAE,SAAqB,EAAE,OAAyB;QAChF,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QANnB,iCAA4B,GAAG,2BAAe,CAAC;QAOtD,IAAI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AAG,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,GAAG,CAAC,IAAI;YAAE,MAAM,IAAI,wBAAgB,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YACpB,oFAAoF;YACpF,MAAM,IAAI,wBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;YACxC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG;SAClC,CAAC;IACJ,CAAC;CACF;AAlBD,gDAkBC;AAYD,IAAA,yBAAa,EAAC,eAAe,EAAE,CAAC,kBAAM,CAAC,SAAS,EAAE,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AAC3E,IAAA,yBAAa,EAAC,kBAAkB,EAAE,CAAC,kBAAM,CAAC,SAAS,EAAE,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KillCursorsOperation = void 0;
|
|
4
|
+
const responses_1 = require("../cmap/wire_protocol/responses");
|
|
4
5
|
const error_1 = require("../error");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
6
|
const operation_1 = require("./operation");
|
|
7
7
|
class KillCursorsOperation extends operation_1.AbstractOperation {
|
|
8
8
|
constructor(cursorId, ns, server, options) {
|
|
9
9
|
super(options);
|
|
10
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
|
10
11
|
this.ns = ns;
|
|
11
12
|
this.cursorId = cursorId;
|
|
12
13
|
this.server = server;
|
|
@@ -14,10 +15,7 @@ class KillCursorsOperation extends operation_1.AbstractOperation {
|
|
|
14
15
|
get commandName() {
|
|
15
16
|
return 'killCursors';
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
if (server !== this.server) {
|
|
19
|
-
throw new error_1.MongoRuntimeError('Killcursor must run on the same server operation began on');
|
|
20
|
-
}
|
|
18
|
+
buildCommand(_connection, _session) {
|
|
21
19
|
const killCursors = this.ns.collection;
|
|
22
20
|
if (killCursors == null) {
|
|
23
21
|
// Cursors should have adopted the namespace returned by MongoDB
|
|
@@ -28,16 +26,16 @@ class KillCursorsOperation extends operation_1.AbstractOperation {
|
|
|
28
26
|
killCursors,
|
|
29
27
|
cursors: [this.cursorId]
|
|
30
28
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
return killCursorsCommand;
|
|
30
|
+
}
|
|
31
|
+
buildOptions(timeoutContext) {
|
|
32
|
+
return {
|
|
33
|
+
session: this.session,
|
|
34
|
+
timeoutContext
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
handleError(_error) {
|
|
38
|
+
// The driver should never emit errors from killCursors, this is spec-ed behavior
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
exports.KillCursorsOperation = KillCursorsOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kill_cursors.js","sourceRoot":"","sources":["../../src/operations/kill_cursors.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"kill_cursors.js","sourceRoot":"","sources":["../../src/operations/kill_cursors.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAClE,oCAA8D;AAK9D,2CAA8F;AAY9F,MAAa,oBAAqB,SAAQ,6BAAuB;IAI/D,YAAY,QAAc,EAAE,EAAoB,EAAE,MAAc,EAAE,OAAyB;QACzF,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,iCAA4B,GAAG,2BAAe,CAAC;QAKtD,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,aAAsB,CAAC;IAChC,CAAC;IAEQ,YAAY,CAAC,WAAuB,EAAE,QAAwB;QACrE,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC;QACvC,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;YACxB,gEAAgE;YAChE,wFAAwF;YACxF,MAAM,IAAI,yBAAiB,CAAC,yDAAyD,CAAC,CAAC;QACzF,CAAC;QAED,MAAM,kBAAkB,GAAuB;YAC7C,WAAW;YACX,OAAO,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,CAAC;QAEF,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAEQ,YAAY,CAAC,cAA8B;QAClD,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,cAAc;SACf,CAAC;IACJ,CAAC;IAEQ,WAAW,CAAC,MAAkB;QACrC,iFAAiF;IACnF,CAAC;CACF;AAzCD,oDAyCC;AAED,IAAA,yBAAa,EAAC,oBAAoB,EAAE,CAAC,kBAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC"}
|
|
@@ -9,6 +9,7 @@ const operation_1 = require("./operation");
|
|
|
9
9
|
class ListCollectionsOperation extends command_1.CommandOperation {
|
|
10
10
|
constructor(db, filter, options) {
|
|
11
11
|
super(db, options);
|
|
12
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
|
12
13
|
this.options = { ...options };
|
|
13
14
|
delete this.options.writeConcern;
|
|
14
15
|
this.db = db;
|
|
@@ -18,15 +19,12 @@ class ListCollectionsOperation extends command_1.CommandOperation {
|
|
|
18
19
|
if (typeof this.options.batchSize === 'number') {
|
|
19
20
|
this.batchSize = this.options.batchSize;
|
|
20
21
|
}
|
|
22
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = this.explain ? responses_1.ExplainedCursorResponse : responses_1.CursorResponse;
|
|
21
23
|
}
|
|
22
24
|
get commandName() {
|
|
23
25
|
return 'listCollections';
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
return await super.executeCommand(server, session, this.generateCommand((0, utils_1.maxWireVersion)(server)), timeoutContext, responses_1.CursorResponse);
|
|
27
|
-
}
|
|
28
|
-
/* This is here for the purpose of unit testing the final command that gets sent. */
|
|
29
|
-
generateCommand(wireVersion) {
|
|
27
|
+
buildCommandDocument(connection) {
|
|
30
28
|
const command = {
|
|
31
29
|
listCollections: 1,
|
|
32
30
|
filter: this.filter,
|
|
@@ -36,11 +34,14 @@ class ListCollectionsOperation extends command_1.CommandOperation {
|
|
|
36
34
|
};
|
|
37
35
|
// we check for undefined specifically here to allow falsy values
|
|
38
36
|
// eslint-disable-next-line no-restricted-syntax
|
|
39
|
-
if (
|
|
37
|
+
if ((0, utils_1.maxWireVersion)(connection) >= 9 && this.options.comment !== undefined) {
|
|
40
38
|
command.comment = this.options.comment;
|
|
41
39
|
}
|
|
42
40
|
return command;
|
|
43
41
|
}
|
|
42
|
+
handleOk(response) {
|
|
43
|
+
return response;
|
|
44
|
+
}
|
|
44
45
|
}
|
|
45
46
|
exports.ListCollectionsOperation = ListCollectionsOperation;
|
|
46
47
|
(0, operation_1.defineAspects)(ListCollectionsOperation, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_collections.js","sourceRoot":"","sources":["../../src/operations/list_collections.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"list_collections.js","sourceRoot":"","sources":["../../src/operations/list_collections.ts"],"names":[],"mappings":";;;AAEA,+DAA0F;AAI1F,oCAA0C;AAC1C,uCAA2E;AAC3E,2CAAoD;AAmBpD,gBAAgB;AAChB,MAAa,wBAAyB,SAAQ,0BAAgC;IAgB5E,YAAY,EAAM,EAAE,MAAgB,EAAE,OAAgC;QACpE,K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AC;YAC1E,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACzC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEQ,QAAQ,CACf,QAAgE;QAEhE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA5DD,4DA4DC;AAcD,IAAA,yBAAa,EAAC,wBAAwB,EAAE;IACtC,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;CACvB,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ListDatabasesOperation = void 0;
|
|
4
|
+
const responses_1 = require("../cmap/wire_protocol/responses");
|
|
4
5
|
const utils_1 = require("../utils");
|
|
5
6
|
const command_1 = require("./command");
|
|
6
7
|
const operation_1 = require("./operation");
|
|
@@ -8,13 +9,14 @@ const operation_1 = require("./operation");
|
|
|
8
9
|
class ListDatabasesOperation extends command_1.CommandOperation {
|
|
9
10
|
constructor(db, options) {
|
|
10
11
|
super(db, options);
|
|
12
|
+
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
|
11
13
|
this.options = options ?? {};
|
|
12
14
|
this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
|
|
13
15
|
}
|
|
14
16
|
get commandName() {
|
|
15
17
|
return 'listDatabases';
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
buildCommandDocument(connection, _session) {
|
|
18
20
|
const cmd = { listDatabases: 1 };
|
|
19
21
|
if (typeof this.options.nameOnly === 'boolean') {
|
|
20
22
|
cmd.nameOnly = this.options.nameOnly;
|
|
@@ -27,10 +29,10 @@ class ListDatabasesOperation extends command_1.CommandOperation {
|
|
|
27
29
|
}
|
|
28
30
|
// we check for undefined specifically here to allow falsy values
|
|
29
31
|
// eslint-disable-next-line no-restricted-syntax
|
|
30
|
-
if ((0, utils_1.maxWireVersion)(
|
|
32
|
+
if ((0, utils_1.maxWireVersion)(connection) >= 9 && this.options.comment !== undefined) {
|
|
31
33
|
cmd.comment = this.options.comment;
|
|
32
34
|
}
|
|
33
|
-
return
|
|
35
|
+
return cmd;
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
exports.ListDatabasesOperation = ListDatabasesOperation;
|