@mongosh/shell-api 2.1.1 → 2.1.4
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/AUTHORS +1 -0
- package/lib/abstract-cursor.js +176 -132
- package/lib/abstract-cursor.js.map +1 -1
- package/lib/aggregate-or-find-cursor.js +102 -51
- package/lib/aggregate-or-find-cursor.js.map +1 -1
- package/lib/aggregation-cursor.js +59 -13
- package/lib/aggregation-cursor.js.map +1 -1
- package/lib/bulk.js +248 -197
- package/lib/bulk.js.map +1 -1
- package/lib/change-stream-cursor.js +145 -101
- package/lib/change-stream-cursor.js.map +1 -1
- package/lib/collection.d.ts +2 -1
- package/lib/collection.js +1185 -1245
- package/lib/collection.js.map +1 -1
- package/lib/cursor.js +238 -203
- package/lib/cursor.js.map +1 -1
- package/lib/database.js +1189 -1206
- package/lib/database.js.map +1 -1
- package/lib/dbquery.js +68 -22
- package/lib/dbquery.js.map +1 -1
- package/lib/decorators.d.ts +39 -13
- package/lib/decorators.js +34 -34
- package/lib/decorators.js.map +1 -1
- package/lib/explainable-cursor.js +66 -20
- package/lib/explainable-cursor.js.map +1 -1
- package/lib/explainable.js +214 -179
- package/lib/explainable.js.map +1 -1
- package/lib/field-level-encryption.js +286 -235
- package/lib/field-level-encryption.js.map +1 -1
- package/lib/helpers.d.ts +9 -1
- package/lib/helpers.js +24 -17
- package/lib/helpers.js.map +1 -1
- package/lib/interruptor.js.map +1 -1
- package/lib/log-entry.js.map +1 -1
- package/lib/mongo-errors.js +3 -1
- package/lib/mongo-errors.js.map +1 -1
- package/lib/mongo.js +581 -547
- package/lib/mongo.js.map +1 -1
- package/lib/plan-cache.js +108 -64
- package/lib/plan-cache.js.map +1 -1
- package/lib/replica-set.js +290 -277
- package/lib/replica-set.js.map +1 -1
- package/lib/result.js +228 -91
- package/lib/result.js.map +1 -1
- package/lib/run-command-cursor.js +59 -13
- package/lib/run-command-cursor.js.map +1 -1
- package/lib/session.js +123 -76
- package/lib/session.js.map +1 -1
- package/lib/shard.js +507 -514
- package/lib/shard.js.map +1 -1
- package/lib/shell-api.js +313 -268
- package/lib/shell-api.js.map +1 -1
- package/lib/shell-bson.js.map +1 -1
- package/lib/shell-instance-state.js.map +1 -1
- package/lib/stream-processor.js +139 -92
- package/lib/stream-processor.js.map +1 -1
- package/lib/streams.js +158 -110
- package/lib/streams.js.map +1 -1
- package/package.json +10 -10
package/lib/collection.js
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
7
39
|
};
|
|
8
40
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -19,1311 +51,1219 @@ const history_1 = require("@mongosh/history");
|
|
|
19
51
|
const plan_cache_1 = __importDefault(require("./plan-cache"));
|
|
20
52
|
const change_stream_cursor_1 = __importDefault(require("./change-stream-cursor"));
|
|
21
53
|
const error_codes_1 = require("./error-codes");
|
|
22
|
-
let Collection =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return (0, helpers_1.maybeMarkAsExplainOutput)(await this._mongo._serviceProvider.distinct(this._database._name, this._name, field, query, { ...(await this._database._baseOptions()), ...options }), options);
|
|
117
|
-
}
|
|
118
|
-
async estimatedDocumentCount(options = {}) {
|
|
119
|
-
this._emitCollectionApiCall('estimatedDocumentCount', { options });
|
|
120
|
-
return this._mongo._serviceProvider.estimatedDocumentCount(this._database._name, this._name, { ...(await this._database._baseOptions()), ...options });
|
|
121
|
-
}
|
|
122
|
-
async find(query, projection, options = {}) {
|
|
123
|
-
if (projection) {
|
|
124
|
-
options.projection = projection;
|
|
125
|
-
}
|
|
126
|
-
this._emitCollectionApiCall('find', { query, options });
|
|
127
|
-
const cursor = new index_1.Cursor(this._mongo, this._mongo._serviceProvider.find(this._database._name, this._name, query, { ...(await this._database._baseOptions()), ...options }));
|
|
128
|
-
this._mongo._instanceState.currentCursor = cursor;
|
|
129
|
-
return cursor;
|
|
130
|
-
}
|
|
131
|
-
async findAndModify(options) {
|
|
132
|
-
(0, helpers_1.assertArgsDefinedType)([options], [true], 'Collection.findAndModify');
|
|
133
|
-
(0, helpers_1.assertKeysDefined)(options, ['query']);
|
|
134
|
-
this._emitCollectionApiCall('findAndModify', {
|
|
135
|
-
options: { ...options, update: !!options.update },
|
|
136
|
-
});
|
|
137
|
-
const reducedOptions = { ...options };
|
|
138
|
-
delete reducedOptions.query;
|
|
139
|
-
delete reducedOptions.update;
|
|
140
|
-
if (options.remove) {
|
|
141
|
-
return this.findOneAndDelete(options.query, reducedOptions);
|
|
142
|
-
}
|
|
143
|
-
const { update } = options;
|
|
144
|
-
if (!update) {
|
|
145
|
-
throw new errors_1.MongoshInvalidInputError('Must specify options.update or options.remove', errors_1.CommonErrors.InvalidArgument);
|
|
146
|
-
}
|
|
147
|
-
if (Array.isArray(update) ||
|
|
148
|
-
Object.keys(update).some((key) => key.startsWith('$'))) {
|
|
149
|
-
return this.findOneAndUpdate(options.query, update, reducedOptions);
|
|
150
|
-
}
|
|
151
|
-
return this.findOneAndReplace(options.query, update, reducedOptions);
|
|
152
|
-
}
|
|
153
|
-
async findOne(query = {}, projection, options = {}) {
|
|
154
|
-
if (projection) {
|
|
155
|
-
options.projection = projection;
|
|
156
|
-
}
|
|
157
|
-
this._emitCollectionApiCall('findOne', { query, options });
|
|
158
|
-
return new index_1.Cursor(this._mongo, this._mongo._serviceProvider.find(this._database._name, this._name, query, { ...(await this._database._baseOptions()), ...options }))
|
|
159
|
-
.limit(1)
|
|
160
|
-
.tryNext();
|
|
161
|
-
}
|
|
162
|
-
async renameCollection(newName, dropTarget) {
|
|
163
|
-
(0, helpers_1.assertArgsDefinedType)([newName], ['string'], 'Collection.renameCollection');
|
|
164
|
-
this._emitCollectionApiCall('renameCollection', { newName, dropTarget });
|
|
165
|
-
try {
|
|
166
|
-
await this._mongo._serviceProvider.renameCollection(this._database._name, this._name, newName, { ...(await this._database._baseOptions()), dropTarget: !!dropTarget });
|
|
167
|
-
return {
|
|
168
|
-
ok: 1,
|
|
169
|
-
};
|
|
54
|
+
let Collection = (() => {
|
|
55
|
+
let _classDecorators = [decorators_1.shellApiClassDefault, decorators_1.addSourceToResults];
|
|
56
|
+
let _classDescriptor;
|
|
57
|
+
let _classExtraInitializers = [];
|
|
58
|
+
let _classThis;
|
|
59
|
+
let _classSuper = decorators_1.ShellApiWithMongoClass;
|
|
60
|
+
let _instanceExtraInitializers = [];
|
|
61
|
+
let _aggregate_decorators;
|
|
62
|
+
let _bulkWrite_decorators;
|
|
63
|
+
let _count_decorators;
|
|
64
|
+
let _countDocuments_decorators;
|
|
65
|
+
let _deleteMany_decorators;
|
|
66
|
+
let _deleteOne_decorators;
|
|
67
|
+
let _distinct_decorators;
|
|
68
|
+
let _estimatedDocumentCount_decorators;
|
|
69
|
+
let _find_decorators;
|
|
70
|
+
let _findAndModify_decorators;
|
|
71
|
+
let _findOne_decorators;
|
|
72
|
+
let _renameCollection_decorators;
|
|
73
|
+
let _findOneAndDelete_decorators;
|
|
74
|
+
let _findOneAndReplace_decorators;
|
|
75
|
+
let _findOneAndUpdate_decorators;
|
|
76
|
+
let _insert_decorators;
|
|
77
|
+
let _insertMany_decorators;
|
|
78
|
+
let _insertOne_decorators;
|
|
79
|
+
let _isCapped_decorators;
|
|
80
|
+
let _remove_decorators;
|
|
81
|
+
let _replaceOne_decorators;
|
|
82
|
+
let _update_decorators;
|
|
83
|
+
let _updateMany_decorators;
|
|
84
|
+
let _updateOne_decorators;
|
|
85
|
+
let _compactStructuredEncryptionData_decorators;
|
|
86
|
+
let _convertToCapped_decorators;
|
|
87
|
+
let _createIndexes_decorators;
|
|
88
|
+
let _createIndex_decorators;
|
|
89
|
+
let _ensureIndex_decorators;
|
|
90
|
+
let _getIndexes_decorators;
|
|
91
|
+
let _getIndexSpecs_decorators;
|
|
92
|
+
let _getIndices_decorators;
|
|
93
|
+
let _getIndexKeys_decorators;
|
|
94
|
+
let _dropIndexes_decorators;
|
|
95
|
+
let _dropIndex_decorators;
|
|
96
|
+
let _totalIndexSize_decorators;
|
|
97
|
+
let _reIndex_decorators;
|
|
98
|
+
let _getDB_decorators;
|
|
99
|
+
let _getMongo_decorators;
|
|
100
|
+
let _dataSize_decorators;
|
|
101
|
+
let _storageSize_decorators;
|
|
102
|
+
let _totalSize_decorators;
|
|
103
|
+
let _drop_decorators;
|
|
104
|
+
let _exists_decorators;
|
|
105
|
+
let _runCommand_decorators;
|
|
106
|
+
let _explain_decorators;
|
|
107
|
+
let _stats_decorators;
|
|
108
|
+
let _latencyStats_decorators;
|
|
109
|
+
let _initializeOrderedBulkOp_decorators;
|
|
110
|
+
let _initializeUnorderedBulkOp_decorators;
|
|
111
|
+
let _getPlanCache_decorators;
|
|
112
|
+
let _mapReduce_decorators;
|
|
113
|
+
let _validate_decorators;
|
|
114
|
+
let _getShardVersion_decorators;
|
|
115
|
+
let _getShardDistribution_decorators;
|
|
116
|
+
let _watch_decorators;
|
|
117
|
+
let _hideIndex_decorators;
|
|
118
|
+
let _unhideIndex_decorators;
|
|
119
|
+
let _analyzeShardKey_decorators;
|
|
120
|
+
let _configureQueryAnalyzer_decorators;
|
|
121
|
+
let _checkMetadataConsistency_decorators;
|
|
122
|
+
let _getSearchIndexes_decorators;
|
|
123
|
+
let _createSearchIndex_decorators;
|
|
124
|
+
let _createSearchIndexes_decorators;
|
|
125
|
+
let _dropSearchIndex_decorators;
|
|
126
|
+
let _updateSearchIndex_decorators;
|
|
127
|
+
var Collection = _classThis = class extends _classSuper {
|
|
128
|
+
constructor(mongo, database, name) {
|
|
129
|
+
super();
|
|
130
|
+
this._mongo = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
131
|
+
this._mongo = mongo;
|
|
132
|
+
this._database = database;
|
|
133
|
+
this._name = name;
|
|
134
|
+
const proxy = new Proxy(this, {
|
|
135
|
+
get: (target, prop) => {
|
|
136
|
+
if (prop in target) {
|
|
137
|
+
return target[prop];
|
|
138
|
+
}
|
|
139
|
+
if (typeof prop !== 'string' ||
|
|
140
|
+
prop.startsWith('_') ||
|
|
141
|
+
!(0, helpers_1.isValidCollectionName)(prop)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
return database.getCollection(`${name}.${prop}`);
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
return proxy;
|
|
170
148
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return {
|
|
174
|
-
ok: 0,
|
|
175
|
-
errmsg: e.errmsg,
|
|
176
|
-
code: e.code,
|
|
177
|
-
codeName: e.codeName,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
throw e;
|
|
149
|
+
[enums_1.namespaceInfo]() {
|
|
150
|
+
return { db: this._database.getName(), collection: this._name };
|
|
181
151
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndDelete');
|
|
185
|
-
this._emitCollectionApiCall('findOneAndDelete', { filter, options });
|
|
186
|
-
const result = await this._mongo._serviceProvider.findOneAndDelete(this._database._name, this._name, filter, { ...(await this._database._baseOptions()), ...options });
|
|
187
|
-
if (options.explain && result) {
|
|
188
|
-
return (0, helpers_1.markAsExplainOutput)(result);
|
|
189
|
-
}
|
|
190
|
-
return result === null || result === void 0 ? void 0 : result.value;
|
|
191
|
-
}
|
|
192
|
-
async findOneAndReplace(filter, replacement, options = {}) {
|
|
193
|
-
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndReplace');
|
|
194
|
-
const findOneAndReplaceOptions = (0, helpers_1.processFindAndModifyOptions)({
|
|
195
|
-
...(await this._database._baseOptions()),
|
|
196
|
-
...options,
|
|
197
|
-
});
|
|
198
|
-
this._emitCollectionApiCall('findOneAndReplace', {
|
|
199
|
-
filter,
|
|
200
|
-
findOneAndReplaceOptions,
|
|
201
|
-
});
|
|
202
|
-
const result = await this._mongo._serviceProvider.findOneAndReplace(this._database._name, this._name, filter, replacement, findOneAndReplaceOptions);
|
|
203
|
-
if (options.explain) {
|
|
204
|
-
return (0, helpers_1.markAsExplainOutput)(result);
|
|
205
|
-
}
|
|
206
|
-
return result.value;
|
|
207
|
-
}
|
|
208
|
-
async findOneAndUpdate(filter, update, options = {}) {
|
|
209
|
-
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndUpdate');
|
|
210
|
-
const findOneAndUpdateOptions = (0, helpers_1.processFindAndModifyOptions)({
|
|
211
|
-
...(await this._database._baseOptions()),
|
|
212
|
-
...options,
|
|
213
|
-
});
|
|
214
|
-
this._emitCollectionApiCall('findOneAndUpdate', {
|
|
215
|
-
filter,
|
|
216
|
-
findOneAndUpdateOptions,
|
|
217
|
-
});
|
|
218
|
-
const result = await this._mongo._serviceProvider.findOneAndUpdate(this._database._name, this._name, filter, update, findOneAndUpdateOptions);
|
|
219
|
-
if (options.explain) {
|
|
220
|
-
return (0, helpers_1.markAsExplainOutput)(result);
|
|
221
|
-
}
|
|
222
|
-
return result.value;
|
|
223
|
-
}
|
|
224
|
-
async insert(docs, options = {}) {
|
|
225
|
-
await this._instanceState.printDeprecationWarning('Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite.');
|
|
226
|
-
(0, helpers_1.assertArgsDefinedType)([docs], [true], 'Collection.insert');
|
|
227
|
-
const docsToInsert = Array.isArray(docs)
|
|
228
|
-
? docs.map((doc) => ({ ...doc }))
|
|
229
|
-
: [{ ...docs }];
|
|
230
|
-
this._emitCollectionApiCall('insert', { options });
|
|
231
|
-
const result = await this._mongo._serviceProvider.insertMany(this._database._name, this._name, docsToInsert, { ...(await this._database._baseOptions()), ...options });
|
|
232
|
-
return new index_1.InsertManyResult(!!result.acknowledged, result.insertedIds);
|
|
233
|
-
}
|
|
234
|
-
async insertMany(docs, options = {}) {
|
|
235
|
-
(0, helpers_1.assertArgsDefinedType)([docs], [true], 'Collection.insertMany');
|
|
236
|
-
const docsToInsert = Array.isArray(docs)
|
|
237
|
-
? docs.map((doc) => ({ ...doc }))
|
|
238
|
-
: docs;
|
|
239
|
-
this._emitCollectionApiCall('insertMany', { options });
|
|
240
|
-
const result = await this._mongo._serviceProvider.insertMany(this._database._name, this._name, docsToInsert, { ...(await this._database._baseOptions()), ...options });
|
|
241
|
-
return new index_1.InsertManyResult(!!result.acknowledged, result.insertedIds);
|
|
242
|
-
}
|
|
243
|
-
async insertOne(doc, options = {}) {
|
|
244
|
-
(0, helpers_1.assertArgsDefinedType)([doc], [true], 'Collection.insertOne');
|
|
245
|
-
this._emitCollectionApiCall('insertOne', { options });
|
|
246
|
-
const result = await this._mongo._serviceProvider.insertOne(this._database._name, this._name, { ...doc }, { ...(await this._database._baseOptions()), ...options });
|
|
247
|
-
return new index_1.InsertOneResult(!!result.acknowledged, result.insertedId);
|
|
248
|
-
}
|
|
249
|
-
async isCapped() {
|
|
250
|
-
var _a, _b;
|
|
251
|
-
this._emitCollectionApiCall('isCapped');
|
|
252
|
-
const colls = await this._database._listCollections({ name: this._name }, { nameOnly: false });
|
|
253
|
-
if (colls.length === 0) {
|
|
254
|
-
throw new errors_1.MongoshRuntimeError(`collection ${this.getFullName()} not found`);
|
|
255
|
-
}
|
|
256
|
-
return !!((_b = (_a = colls[0]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.capped);
|
|
257
|
-
}
|
|
258
|
-
async remove(query, options = {}) {
|
|
259
|
-
await this._instanceState.printDeprecationWarning('Collection.remove() is deprecated. Use deleteOne, deleteMany, findOneAndDelete, or bulkWrite.');
|
|
260
|
-
(0, helpers_1.assertArgsDefinedType)([query], [true], 'Collection.remove');
|
|
261
|
-
const removeOptions = (0, helpers_1.processRemoveOptions)(options);
|
|
262
|
-
const method = removeOptions.justOne ? 'deleteOne' : 'deleteMany';
|
|
263
|
-
delete removeOptions.justOne;
|
|
264
|
-
this._emitCollectionApiCall('remove', { query, removeOptions });
|
|
265
|
-
const result = await this._mongo._serviceProvider[method](this._database._name, this._name, query, { ...(await this._database._baseOptions()), ...removeOptions });
|
|
266
|
-
if (removeOptions.explain) {
|
|
267
|
-
return (0, helpers_1.markAsExplainOutput)(result);
|
|
268
|
-
}
|
|
269
|
-
return new index_1.DeleteResult(!!result.acknowledged, result.deletedCount);
|
|
270
|
-
}
|
|
271
|
-
async replaceOne(filter, replacement, options = {}) {
|
|
272
|
-
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.replaceOne');
|
|
273
|
-
this._emitCollectionApiCall('replaceOne', { filter, options });
|
|
274
|
-
const result = await this._mongo._serviceProvider.replaceOne(this._database._name, this._name, filter, replacement, { ...(await this._database._baseOptions()), ...options });
|
|
275
|
-
return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
|
|
276
|
-
}
|
|
277
|
-
async update(filter, update, options = {}) {
|
|
278
|
-
await this._instanceState.printDeprecationWarning('Collection.update() is deprecated. Use updateOne, updateMany, or bulkWrite.');
|
|
279
|
-
(0, helpers_1.assertArgsDefinedType)([filter, update], [true, true], 'Collection.update');
|
|
280
|
-
this._emitCollectionApiCall('update', { filter, options });
|
|
281
|
-
let result;
|
|
282
|
-
if (options.multi) {
|
|
283
|
-
result = await this._mongo._serviceProvider.updateMany(this._database._name, this._name, filter, update, { ...(await this._database._baseOptions()), ...options });
|
|
152
|
+
[enums_1.asPrintable]() {
|
|
153
|
+
return `${this._database.getName()}.${this._name}`;
|
|
284
154
|
}
|
|
285
|
-
|
|
286
|
-
|
|
155
|
+
_emitCollectionApiCall(methodName, methodArguments = {}) {
|
|
156
|
+
this._mongo._instanceState.emitApiCallWithArgs({
|
|
157
|
+
method: methodName,
|
|
158
|
+
class: 'Collection',
|
|
159
|
+
db: this._database._name,
|
|
160
|
+
coll: this._name,
|
|
161
|
+
arguments: methodArguments,
|
|
162
|
+
});
|
|
287
163
|
}
|
|
288
|
-
|
|
289
|
-
|
|
164
|
+
async aggregate(...args) {
|
|
165
|
+
let options;
|
|
166
|
+
let pipeline;
|
|
167
|
+
if (args.length === 0 || Array.isArray(args[0])) {
|
|
168
|
+
options = args[1] || {};
|
|
169
|
+
pipeline = args[0] || [];
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
options = {};
|
|
173
|
+
pipeline = args || [];
|
|
174
|
+
}
|
|
175
|
+
this._emitCollectionApiCall('aggregate', { options, pipeline });
|
|
176
|
+
const { aggOptions, dbOptions, explain } = (0, helpers_1.adaptAggregateOptions)(options);
|
|
177
|
+
const providerCursor = this._mongo._serviceProvider.aggregate(this._database._name, this._name, pipeline, { ...(await this._database._baseOptions()), ...aggOptions }, dbOptions);
|
|
178
|
+
const cursor = new index_1.AggregationCursor(this._mongo, providerCursor);
|
|
179
|
+
if (explain) {
|
|
180
|
+
return await cursor.explain(explain);
|
|
181
|
+
}
|
|
182
|
+
else if ((0, helpers_1.shouldRunAggregationImmediately)(pipeline)) {
|
|
183
|
+
await cursor.hasNext();
|
|
184
|
+
}
|
|
185
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
186
|
+
return cursor;
|
|
187
|
+
}
|
|
188
|
+
async bulkWrite(operations, options = {}) {
|
|
189
|
+
this._emitCollectionApiCall('bulkWrite', { options });
|
|
190
|
+
const result = await this._mongo._serviceProvider.bulkWrite(this._database._name, this._name, operations, { ...(await this._database._baseOptions()), ...options });
|
|
191
|
+
return new index_1.BulkWriteResult(!!result.ok, result.insertedCount, result.insertedIds, result.matchedCount, result.modifiedCount, result.deletedCount, result.upsertedCount, result.upsertedIds);
|
|
192
|
+
}
|
|
193
|
+
async count(query = {}, options = {}) {
|
|
194
|
+
await this._instanceState.printDeprecationWarning('Collection.count() is deprecated. Use countDocuments or estimatedDocumentCount.');
|
|
195
|
+
this._emitCollectionApiCall('count', { query, options });
|
|
196
|
+
return this._mongo._serviceProvider.count(this._database._name, this._name, query, { ...(await this._database._baseOptions()), ...options });
|
|
197
|
+
}
|
|
198
|
+
async countDocuments(query, options = {}) {
|
|
199
|
+
this._emitCollectionApiCall('countDocuments', { query, options });
|
|
200
|
+
return this._mongo._serviceProvider.countDocuments(this._database._name, this._name, query, { ...(await this._database._baseOptions()), ...options });
|
|
201
|
+
}
|
|
202
|
+
async deleteMany(filter, options = {}) {
|
|
203
|
+
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.deleteMany');
|
|
204
|
+
this._emitCollectionApiCall('deleteMany', { filter, options });
|
|
205
|
+
const result = await this._mongo._serviceProvider.deleteMany(this._database._name, this._name, filter, { ...(await this._database._baseOptions()), ...options });
|
|
206
|
+
if (options.explain) {
|
|
207
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
208
|
+
}
|
|
209
|
+
return new index_1.DeleteResult(!!result.acknowledged, result.deletedCount);
|
|
210
|
+
}
|
|
211
|
+
async deleteOne(filter, options = {}) {
|
|
212
|
+
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.deleteOne');
|
|
213
|
+
this._emitCollectionApiCall('deleteOne', { filter, options });
|
|
214
|
+
const result = await this._mongo._serviceProvider.deleteOne(this._database._name, this._name, filter, { ...(await this._database._baseOptions()), ...options });
|
|
215
|
+
if (options.explain) {
|
|
216
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
217
|
+
}
|
|
218
|
+
return new index_1.DeleteResult(!!result.acknowledged, result.deletedCount);
|
|
290
219
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.updateMany');
|
|
295
|
-
this._emitCollectionApiCall('updateMany', { filter, options });
|
|
296
|
-
const result = await this._mongo._serviceProvider.updateMany(this._database._name, this._name, filter, update, { ...(await this._database._baseOptions()), ...options });
|
|
297
|
-
if (options.explain) {
|
|
298
|
-
return (0, helpers_1.markAsExplainOutput)(result);
|
|
299
|
-
}
|
|
300
|
-
return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
|
|
301
|
-
}
|
|
302
|
-
async updateOne(filter, update, options = {}) {
|
|
303
|
-
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.updateOne');
|
|
304
|
-
this._emitCollectionApiCall('updateOne', { filter, options });
|
|
305
|
-
const result = await this._mongo._serviceProvider.updateOne(this._database._name, this._name, filter, update, { ...(await this._database._baseOptions()), ...options });
|
|
306
|
-
if (options.explain) {
|
|
307
|
-
return (0, helpers_1.markAsExplainOutput)(result);
|
|
308
|
-
}
|
|
309
|
-
return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
|
|
310
|
-
}
|
|
311
|
-
async compactStructuredEncryptionData() {
|
|
312
|
-
if (!this._mongo._fleOptions) {
|
|
313
|
-
throw new errors_1.MongoshInvalidInputError('The "compactStructuredEncryptionData" command requires Mongo instance configured with auto encryption.', errors_1.CommonErrors.InvalidArgument);
|
|
314
|
-
}
|
|
315
|
-
this._emitCollectionApiCall('compactStructuredEncryptionData');
|
|
316
|
-
return await this._database._runCommand({
|
|
317
|
-
compactStructuredEncryptionData: this._name,
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
async convertToCapped(size) {
|
|
321
|
-
this._emitCollectionApiCall('convertToCapped', { size });
|
|
322
|
-
return await this._database._runCommand({
|
|
323
|
-
convertToCapped: this._name,
|
|
324
|
-
size,
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
async _createIndexes(keyPatterns, options = {}, commitQuorum) {
|
|
328
|
-
(0, helpers_1.assertArgsDefinedType)([keyPatterns], [true], 'Collection.createIndexes');
|
|
329
|
-
if (typeof options !== 'object' || Array.isArray(options)) {
|
|
330
|
-
throw new errors_1.MongoshInvalidInputError('The "options" argument must be an object.', errors_1.CommonErrors.InvalidArgument);
|
|
331
|
-
}
|
|
332
|
-
const specs = keyPatterns.map((pattern) => ({
|
|
333
|
-
...options,
|
|
334
|
-
key: pattern,
|
|
335
|
-
}));
|
|
336
|
-
const createIndexesOptions = {
|
|
337
|
-
...(await this._database._baseOptions()),
|
|
338
|
-
...options,
|
|
339
|
-
};
|
|
340
|
-
if (undefined !== commitQuorum) {
|
|
341
|
-
createIndexesOptions.commitQuorum = commitQuorum;
|
|
342
|
-
}
|
|
343
|
-
return await this._mongo._serviceProvider.createIndexes(this._database._name, this._name, specs, createIndexesOptions);
|
|
344
|
-
}
|
|
345
|
-
async createIndexes(keyPatterns, options = {}, commitQuorum) {
|
|
346
|
-
const specs = keyPatterns.map((pattern) => ({
|
|
347
|
-
...options,
|
|
348
|
-
key: pattern,
|
|
349
|
-
}));
|
|
350
|
-
this._emitCollectionApiCall('createIndexes', { specs });
|
|
351
|
-
return this._createIndexes(keyPatterns, options, commitQuorum);
|
|
352
|
-
}
|
|
353
|
-
async createIndex(keys, options = {}, commitQuorum) {
|
|
354
|
-
(0, helpers_1.assertArgsDefinedType)([keys], [true], 'Collection.createIndex');
|
|
355
|
-
if (typeof options !== 'object' || Array.isArray(options)) {
|
|
356
|
-
throw new errors_1.MongoshInvalidInputError('The "options" argument must be an object.', errors_1.CommonErrors.InvalidArgument);
|
|
220
|
+
async distinct(field, query, options = {}) {
|
|
221
|
+
this._emitCollectionApiCall('distinct', { field, query, options });
|
|
222
|
+
return (0, helpers_1.maybeMarkAsExplainOutput)(await this._mongo._serviceProvider.distinct(this._database._name, this._name, field, query, { ...(await this._database._baseOptions()), ...options }), options);
|
|
357
223
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
throw new errors_1.MongoshInternalError(`Expected createIndexes() to return array of length 1, saw ${names.toString()}`);
|
|
224
|
+
async estimatedDocumentCount(options = {}) {
|
|
225
|
+
this._emitCollectionApiCall('estimatedDocumentCount', { options });
|
|
226
|
+
return this._mongo._serviceProvider.estimatedDocumentCount(this._database._name, this._name, { ...(await this._database._baseOptions()), ...options });
|
|
362
227
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
async getIndices() {
|
|
378
|
-
this._emitCollectionApiCall('getIndices');
|
|
379
|
-
return await this._mongo._serviceProvider.getIndexes(this._database._name, this._name, await this._database._baseOptions());
|
|
380
|
-
}
|
|
381
|
-
async getIndexKeys() {
|
|
382
|
-
this._emitCollectionApiCall('getIndexKeys');
|
|
383
|
-
const indexes = await this._mongo._serviceProvider.getIndexes(this._database._name, this._name, await this._database._baseOptions());
|
|
384
|
-
return indexes.map((i) => i.key);
|
|
385
|
-
}
|
|
386
|
-
async dropIndexes(indexes = '*') {
|
|
387
|
-
this._emitCollectionApiCall('dropIndexes', { indexes });
|
|
388
|
-
try {
|
|
389
|
-
return await this._database._runCommand({
|
|
390
|
-
dropIndexes: this._name,
|
|
391
|
-
index: indexes,
|
|
228
|
+
async find(query, projection, options = {}) {
|
|
229
|
+
if (projection) {
|
|
230
|
+
options.projection = projection;
|
|
231
|
+
}
|
|
232
|
+
this._emitCollectionApiCall('find', { query, options });
|
|
233
|
+
const cursor = new index_1.Cursor(this._mongo, this._mongo._serviceProvider.find(this._database._name, this._name, query, { ...(await this._database._baseOptions()), ...options }));
|
|
234
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
235
|
+
return cursor;
|
|
236
|
+
}
|
|
237
|
+
async findAndModify(options) {
|
|
238
|
+
(0, helpers_1.assertArgsDefinedType)([options], [true], 'Collection.findAndModify');
|
|
239
|
+
(0, helpers_1.assertKeysDefined)(options, ['query']);
|
|
240
|
+
this._emitCollectionApiCall('findAndModify', {
|
|
241
|
+
options: { ...options, update: !!options.update },
|
|
392
242
|
});
|
|
243
|
+
const reducedOptions = { ...options };
|
|
244
|
+
delete reducedOptions.query;
|
|
245
|
+
delete reducedOptions.update;
|
|
246
|
+
if (options.remove) {
|
|
247
|
+
return this.findOneAndDelete(options.query, reducedOptions);
|
|
248
|
+
}
|
|
249
|
+
const { update } = options;
|
|
250
|
+
if (!update) {
|
|
251
|
+
throw new errors_1.MongoshInvalidInputError('Must specify options.update or options.remove', errors_1.CommonErrors.InvalidArgument);
|
|
252
|
+
}
|
|
253
|
+
if (Array.isArray(update) ||
|
|
254
|
+
Object.keys(update).some((key) => key.startsWith('$'))) {
|
|
255
|
+
return this.findOneAndUpdate(options.query, update, reducedOptions);
|
|
256
|
+
}
|
|
257
|
+
return this.findOneAndReplace(options.query, update, reducedOptions);
|
|
393
258
|
}
|
|
394
|
-
|
|
395
|
-
if (
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'IndexNotFound') {
|
|
259
|
+
async findOne(query = {}, projection, options = {}) {
|
|
260
|
+
if (projection) {
|
|
261
|
+
options.projection = projection;
|
|
262
|
+
}
|
|
263
|
+
this._emitCollectionApiCall('findOne', { query, options });
|
|
264
|
+
return new index_1.Cursor(this._mongo, this._mongo._serviceProvider.find(this._database._name, this._name, query, { ...(await this._database._baseOptions()), ...options }))
|
|
265
|
+
.limit(1)
|
|
266
|
+
.tryNext();
|
|
267
|
+
}
|
|
268
|
+
async renameCollection(newName, dropTarget) {
|
|
269
|
+
(0, helpers_1.assertArgsDefinedType)([newName], ['string'], 'Collection.renameCollection');
|
|
270
|
+
this._emitCollectionApiCall('renameCollection', { newName, dropTarget });
|
|
271
|
+
try {
|
|
272
|
+
await this._mongo._serviceProvider.renameCollection(this._database._name, this._name, newName, { ...(await this._database._baseOptions()), dropTarget: !!dropTarget });
|
|
409
273
|
return {
|
|
410
|
-
ok:
|
|
411
|
-
errmsg: error.errmsg,
|
|
412
|
-
code: error.code,
|
|
413
|
-
codeName: error.codeName,
|
|
274
|
+
ok: 1,
|
|
414
275
|
};
|
|
415
276
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
277
|
+
catch (e) {
|
|
278
|
+
if ((e === null || e === void 0 ? void 0 : e.name) === 'MongoError') {
|
|
279
|
+
return {
|
|
280
|
+
ok: 0,
|
|
281
|
+
errmsg: e.errmsg,
|
|
282
|
+
code: e.code,
|
|
283
|
+
codeName: e.codeName,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
throw e;
|
|
287
|
+
}
|
|
424
288
|
}
|
|
425
|
-
|
|
426
|
-
|
|
289
|
+
async findOneAndDelete(filter, options = {}) {
|
|
290
|
+
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndDelete');
|
|
291
|
+
this._emitCollectionApiCall('findOneAndDelete', { filter, options });
|
|
292
|
+
const result = await this._mongo._serviceProvider.findOneAndDelete(this._database._name, this._name, filter, { ...(await this._database._baseOptions()), ...options });
|
|
293
|
+
if (options.explain && result) {
|
|
294
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
295
|
+
}
|
|
296
|
+
return result === null || result === void 0 ? void 0 : result.value;
|
|
427
297
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
298
|
+
async findOneAndReplace(filter, replacement, options = {}) {
|
|
299
|
+
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndReplace');
|
|
300
|
+
const findOneAndReplaceOptions = (0, helpers_1.processFindAndModifyOptions)({
|
|
301
|
+
...(await this._database._baseOptions()),
|
|
302
|
+
...options,
|
|
303
|
+
});
|
|
304
|
+
this._emitCollectionApiCall('findOneAndReplace', {
|
|
305
|
+
filter,
|
|
306
|
+
findOneAndReplaceOptions,
|
|
307
|
+
});
|
|
308
|
+
const result = await this._mongo._serviceProvider.findOneAndReplace(this._database._name, this._name, filter, replacement, findOneAndReplaceOptions);
|
|
309
|
+
if (options.explain) {
|
|
310
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
311
|
+
}
|
|
312
|
+
return result.value;
|
|
442
313
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
this._emitCollectionApiCall('getMongo');
|
|
457
|
-
return this._mongo;
|
|
458
|
-
}
|
|
459
|
-
async dataSize() {
|
|
460
|
-
this._emitCollectionApiCall('dataSize');
|
|
461
|
-
return this._getSingleStorageStatValue('size');
|
|
462
|
-
}
|
|
463
|
-
async storageSize() {
|
|
464
|
-
this._emitCollectionApiCall('storageSize');
|
|
465
|
-
return this._getSingleStorageStatValue('storageSize');
|
|
466
|
-
}
|
|
467
|
-
async totalSize() {
|
|
468
|
-
this._emitCollectionApiCall('totalSize');
|
|
469
|
-
return this._getSingleStorageStatValue('totalSize');
|
|
470
|
-
}
|
|
471
|
-
async drop(options = {}) {
|
|
472
|
-
var _a, _b, _c;
|
|
473
|
-
this._emitCollectionApiCall('drop');
|
|
474
|
-
let encryptedFieldsOptions = {};
|
|
475
|
-
const encryptedFieldsMap = (_a = this._mongo._fleOptions) === null || _a === void 0 ? void 0 : _a.encryptedFieldsMap;
|
|
476
|
-
const encryptedFields = encryptedFieldsMap === null || encryptedFieldsMap === void 0 ? void 0 : encryptedFieldsMap[`${this._database._name}.${this._name}`];
|
|
477
|
-
if (!encryptedFields && !options.encryptedFields) {
|
|
478
|
-
try {
|
|
479
|
-
const collectionInfos = await this._mongo._serviceProvider.listCollections(this._database._name, {
|
|
480
|
-
name: this._name,
|
|
481
|
-
}, await this._database._baseOptions());
|
|
482
|
-
const encryptedFields = (_c = (_b = collectionInfos === null || collectionInfos === void 0 ? void 0 : collectionInfos[0]) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.encryptedFields;
|
|
483
|
-
if (encryptedFields) {
|
|
484
|
-
encryptedFieldsOptions = { encryptedFields };
|
|
485
|
-
}
|
|
314
|
+
async findOneAndUpdate(filter, update, options = {}) {
|
|
315
|
+
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndUpdate');
|
|
316
|
+
const findOneAndUpdateOptions = (0, helpers_1.processFindAndModifyOptions)({
|
|
317
|
+
...(await this._database._baseOptions()),
|
|
318
|
+
...options,
|
|
319
|
+
});
|
|
320
|
+
this._emitCollectionApiCall('findOneAndUpdate', {
|
|
321
|
+
filter,
|
|
322
|
+
findOneAndUpdateOptions,
|
|
323
|
+
});
|
|
324
|
+
const result = await this._mongo._serviceProvider.findOneAndUpdate(this._database._name, this._name, filter, update, findOneAndUpdateOptions);
|
|
325
|
+
if (options.explain) {
|
|
326
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
486
327
|
}
|
|
487
|
-
|
|
328
|
+
return result.value;
|
|
329
|
+
}
|
|
330
|
+
async insert(docs, options = {}) {
|
|
331
|
+
await this._instanceState.printDeprecationWarning('Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite.');
|
|
332
|
+
(0, helpers_1.assertArgsDefinedType)([docs], [true], 'Collection.insert');
|
|
333
|
+
const docsToInsert = Array.isArray(docs)
|
|
334
|
+
? docs.map((doc) => ({ ...doc }))
|
|
335
|
+
: [{ ...docs }];
|
|
336
|
+
this._emitCollectionApiCall('insert', { options });
|
|
337
|
+
const result = await this._mongo._serviceProvider.insertMany(this._database._name, this._name, docsToInsert, { ...(await this._database._baseOptions()), ...options });
|
|
338
|
+
return new index_1.InsertManyResult(!!result.acknowledged, result.insertedIds);
|
|
339
|
+
}
|
|
340
|
+
async insertMany(docs, options = {}) {
|
|
341
|
+
(0, helpers_1.assertArgsDefinedType)([docs], [true], 'Collection.insertMany');
|
|
342
|
+
const docsToInsert = Array.isArray(docs)
|
|
343
|
+
? docs.map((doc) => ({ ...doc }))
|
|
344
|
+
: docs;
|
|
345
|
+
this._emitCollectionApiCall('insertMany', { options });
|
|
346
|
+
const result = await this._mongo._serviceProvider.insertMany(this._database._name, this._name, docsToInsert, { ...(await this._database._baseOptions()), ...options });
|
|
347
|
+
return new index_1.InsertManyResult(!!result.acknowledged, result.insertedIds);
|
|
348
|
+
}
|
|
349
|
+
async insertOne(doc, options = {}) {
|
|
350
|
+
(0, helpers_1.assertArgsDefinedType)([doc], [true], 'Collection.insertOne');
|
|
351
|
+
this._emitCollectionApiCall('insertOne', { options });
|
|
352
|
+
const result = await this._mongo._serviceProvider.insertOne(this._database._name, this._name, { ...doc }, { ...(await this._database._baseOptions()), ...options });
|
|
353
|
+
return new index_1.InsertOneResult(!!result.acknowledged, result.insertedId);
|
|
354
|
+
}
|
|
355
|
+
async isCapped() {
|
|
356
|
+
var _a, _b;
|
|
357
|
+
this._emitCollectionApiCall('isCapped');
|
|
358
|
+
const colls = await this._database._listCollections({ name: this._name }, { nameOnly: false });
|
|
359
|
+
if (colls.length === 0) {
|
|
360
|
+
throw new errors_1.MongoshRuntimeError(`collection ${this.getFullName()} not found`);
|
|
361
|
+
}
|
|
362
|
+
return !!((_b = (_a = colls[0]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.capped);
|
|
363
|
+
}
|
|
364
|
+
async remove(query, options = {}) {
|
|
365
|
+
await this._instanceState.printDeprecationWarning('Collection.remove() is deprecated. Use deleteOne, deleteMany, findOneAndDelete, or bulkWrite.');
|
|
366
|
+
(0, helpers_1.assertArgsDefinedType)([query], [true], 'Collection.remove');
|
|
367
|
+
const removeOptions = (0, helpers_1.processRemoveOptions)(options);
|
|
368
|
+
const method = removeOptions.justOne ? 'deleteOne' : 'deleteMany';
|
|
369
|
+
delete removeOptions.justOne;
|
|
370
|
+
this._emitCollectionApiCall('remove', { query, removeOptions });
|
|
371
|
+
const result = await this._mongo._serviceProvider[method](this._database._name, this._name, query, { ...(await this._database._baseOptions()), ...removeOptions });
|
|
372
|
+
if (removeOptions.explain) {
|
|
373
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
374
|
+
}
|
|
375
|
+
return new index_1.DeleteResult(!!result.acknowledged, result.deletedCount);
|
|
376
|
+
}
|
|
377
|
+
async replaceOne(filter, replacement, options = {}) {
|
|
378
|
+
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.replaceOne');
|
|
379
|
+
this._emitCollectionApiCall('replaceOne', { filter, options });
|
|
380
|
+
const result = await this._mongo._serviceProvider.replaceOne(this._database._name, this._name, filter, replacement, { ...(await this._database._baseOptions()), ...options });
|
|
381
|
+
return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
|
|
382
|
+
}
|
|
383
|
+
async update(filter, update, options = {}) {
|
|
384
|
+
await this._instanceState.printDeprecationWarning('Collection.update() is deprecated. Use updateOne, updateMany, or bulkWrite.');
|
|
385
|
+
(0, helpers_1.assertArgsDefinedType)([filter, update], [true, true], 'Collection.update');
|
|
386
|
+
this._emitCollectionApiCall('update', { filter, options });
|
|
387
|
+
let result;
|
|
388
|
+
if (options.multi) {
|
|
389
|
+
result = await this._mongo._serviceProvider.updateMany(this._database._name, this._name, filter, update, { ...(await this._database._baseOptions()), ...options });
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
result = await this._mongo._serviceProvider.updateOne(this._database._name, this._name, filter, update, { ...(await this._database._baseOptions()), ...options });
|
|
393
|
+
}
|
|
394
|
+
if (options.explain) {
|
|
395
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
488
396
|
}
|
|
397
|
+
return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
|
|
398
|
+
}
|
|
399
|
+
async updateMany(filter, update, options = {}) {
|
|
400
|
+
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.updateMany');
|
|
401
|
+
this._emitCollectionApiCall('updateMany', { filter, options });
|
|
402
|
+
const result = await this._mongo._serviceProvider.updateMany(this._database._name, this._name, filter, update, { ...(await this._database._baseOptions()), ...options });
|
|
403
|
+
if (options.explain) {
|
|
404
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
405
|
+
}
|
|
406
|
+
return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
|
|
407
|
+
}
|
|
408
|
+
async updateOne(filter, update, options = {}) {
|
|
409
|
+
(0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.updateOne');
|
|
410
|
+
this._emitCollectionApiCall('updateOne', { filter, options });
|
|
411
|
+
const result = await this._mongo._serviceProvider.updateOne(this._database._name, this._name, filter, update, { ...(await this._database._baseOptions()), ...options });
|
|
412
|
+
if (options.explain) {
|
|
413
|
+
return (0, helpers_1.markAsExplainOutput)(result);
|
|
414
|
+
}
|
|
415
|
+
return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
|
|
416
|
+
}
|
|
417
|
+
async compactStructuredEncryptionData() {
|
|
418
|
+
if (!this._mongo._fleOptions) {
|
|
419
|
+
throw new errors_1.MongoshInvalidInputError('The "compactStructuredEncryptionData" command requires Mongo instance configured with auto encryption.', errors_1.CommonErrors.InvalidArgument);
|
|
420
|
+
}
|
|
421
|
+
this._emitCollectionApiCall('compactStructuredEncryptionData');
|
|
422
|
+
return await this._database._runCommand({
|
|
423
|
+
compactStructuredEncryptionData: this._name,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
async convertToCapped(size) {
|
|
427
|
+
this._emitCollectionApiCall('convertToCapped', { size });
|
|
428
|
+
return await this._database._runCommand({
|
|
429
|
+
convertToCapped: this._name,
|
|
430
|
+
size,
|
|
431
|
+
});
|
|
489
432
|
}
|
|
490
|
-
|
|
491
|
-
|
|
433
|
+
async _createIndexes(keyPatterns, options = {}, commitQuorum) {
|
|
434
|
+
(0, helpers_1.assertArgsDefinedType)([keyPatterns], [true], 'Collection.createIndexes');
|
|
435
|
+
if (typeof options !== 'object' || Array.isArray(options)) {
|
|
436
|
+
throw new errors_1.MongoshInvalidInputError('The "options" argument must be an object.', errors_1.CommonErrors.InvalidArgument);
|
|
437
|
+
}
|
|
438
|
+
const specs = keyPatterns.map((pattern) => ({
|
|
439
|
+
...options,
|
|
440
|
+
key: pattern,
|
|
441
|
+
}));
|
|
442
|
+
const createIndexesOptions = {
|
|
492
443
|
...(await this._database._baseOptions()),
|
|
493
444
|
...options,
|
|
494
|
-
|
|
495
|
-
|
|
445
|
+
};
|
|
446
|
+
if (undefined !== commitQuorum) {
|
|
447
|
+
createIndexesOptions.commitQuorum = commitQuorum;
|
|
448
|
+
}
|
|
449
|
+
return await this._mongo._serviceProvider.createIndexes(this._database._name, this._name, specs, createIndexesOptions);
|
|
450
|
+
}
|
|
451
|
+
async createIndexes(keyPatterns, options = {}, commitQuorum) {
|
|
452
|
+
const specs = keyPatterns.map((pattern) => ({
|
|
453
|
+
...options,
|
|
454
|
+
key: pattern,
|
|
455
|
+
}));
|
|
456
|
+
this._emitCollectionApiCall('createIndexes', { specs });
|
|
457
|
+
return this._createIndexes(keyPatterns, options, commitQuorum);
|
|
458
|
+
}
|
|
459
|
+
async createIndex(keys, options = {}, commitQuorum) {
|
|
460
|
+
(0, helpers_1.assertArgsDefinedType)([keys], [true], 'Collection.createIndex');
|
|
461
|
+
if (typeof options !== 'object' || Array.isArray(options)) {
|
|
462
|
+
throw new errors_1.MongoshInvalidInputError('The "options" argument must be an object.', errors_1.CommonErrors.InvalidArgument);
|
|
463
|
+
}
|
|
464
|
+
this._emitCollectionApiCall('createIndex', { keys, options });
|
|
465
|
+
const names = await this._createIndexes([keys], options, commitQuorum);
|
|
466
|
+
if (!Array.isArray(names) || names.length !== 1) {
|
|
467
|
+
throw new errors_1.MongoshInternalError(`Expected createIndexes() to return array of length 1, saw ${names.toString()}`);
|
|
468
|
+
}
|
|
469
|
+
return names[0];
|
|
470
|
+
}
|
|
471
|
+
async ensureIndex(keys, options = {}, commitQuorum) {
|
|
472
|
+
this._emitCollectionApiCall('ensureIndex', { keys, options });
|
|
473
|
+
return await this._createIndexes([keys], options, commitQuorum);
|
|
474
|
+
}
|
|
475
|
+
async getIndexes() {
|
|
476
|
+
this._emitCollectionApiCall('getIndexes');
|
|
477
|
+
return await this._mongo._serviceProvider.getIndexes(this._database._name, this._name, await this._database._baseOptions());
|
|
478
|
+
}
|
|
479
|
+
async getIndexSpecs() {
|
|
480
|
+
this._emitCollectionApiCall('getIndexSpecs');
|
|
481
|
+
return await this._mongo._serviceProvider.getIndexes(this._database._name, this._name, await this._database._baseOptions());
|
|
482
|
+
}
|
|
483
|
+
async getIndices() {
|
|
484
|
+
this._emitCollectionApiCall('getIndices');
|
|
485
|
+
return await this._mongo._serviceProvider.getIndexes(this._database._name, this._name, await this._database._baseOptions());
|
|
486
|
+
}
|
|
487
|
+
async getIndexKeys() {
|
|
488
|
+
this._emitCollectionApiCall('getIndexKeys');
|
|
489
|
+
const indexes = await this._mongo._serviceProvider.getIndexes(this._database._name, this._name, await this._database._baseOptions());
|
|
490
|
+
return indexes.map((i) => i.key);
|
|
496
491
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
492
|
+
async dropIndexes(indexes = '*') {
|
|
493
|
+
this._emitCollectionApiCall('dropIndexes', { indexes });
|
|
494
|
+
try {
|
|
495
|
+
return await this._database._runCommand({
|
|
496
|
+
dropIndexes: this._name,
|
|
497
|
+
index: indexes,
|
|
503
498
|
});
|
|
504
|
-
return false;
|
|
505
499
|
}
|
|
506
|
-
|
|
500
|
+
catch (error) {
|
|
501
|
+
if (((error === null || error === void 0 ? void 0 : error.codeName) === 'IndexNotFound' ||
|
|
502
|
+
(error === null || error === void 0 ? void 0 : error.codeName) === undefined) &&
|
|
503
|
+
((error === null || error === void 0 ? void 0 : error.errmsg) === 'invalid index name spec' ||
|
|
504
|
+
(error === null || error === void 0 ? void 0 : error.errmsg) === undefined) &&
|
|
505
|
+
Array.isArray(indexes) &&
|
|
506
|
+
indexes.length > 0 &&
|
|
507
|
+
/^4\.0\./.exec(await this._database.version())) {
|
|
508
|
+
const all = await Promise.all(indexes.map(async (index) => await this.dropIndexes(index)));
|
|
509
|
+
const errored = all.find((result) => !result.ok);
|
|
510
|
+
if (errored)
|
|
511
|
+
return errored;
|
|
512
|
+
return all.sort((a, b) => b.nIndexesWas - a.nIndexesWas)[0];
|
|
513
|
+
}
|
|
514
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'IndexNotFound') {
|
|
515
|
+
return {
|
|
516
|
+
ok: error.ok,
|
|
517
|
+
errmsg: error.errmsg,
|
|
518
|
+
code: error.code,
|
|
519
|
+
codeName: error.codeName,
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
throw error;
|
|
523
|
+
}
|
|
507
524
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}, await this._database._baseOptions());
|
|
514
|
-
return collectionInfos[0] || null;
|
|
515
|
-
}
|
|
516
|
-
getFullName() {
|
|
517
|
-
this._emitCollectionApiCall('getFullName');
|
|
518
|
-
return `${this._database._name}.${this._name}`;
|
|
519
|
-
}
|
|
520
|
-
getName() {
|
|
521
|
-
this._emitCollectionApiCall('getName');
|
|
522
|
-
return `${this._name}`;
|
|
523
|
-
}
|
|
524
|
-
async runCommand(commandName, options) {
|
|
525
|
-
(0, helpers_1.assertArgsDefinedType)([commandName], [['string', 'object']], 'Collection.runCommand');
|
|
526
|
-
if (options) {
|
|
527
|
-
if (typeof commandName !== 'string') {
|
|
528
|
-
throw new errors_1.MongoshInvalidInputError('Collection.runCommand takes a command string as its first arugment', errors_1.CommonErrors.InvalidArgument);
|
|
525
|
+
async dropIndex(index) {
|
|
526
|
+
(0, helpers_1.assertArgsDefinedType)([index], [true], 'Collection.dropIndex');
|
|
527
|
+
this._emitCollectionApiCall('dropIndex', { index });
|
|
528
|
+
if (index === '*') {
|
|
529
|
+
throw new errors_1.MongoshInvalidInputError("To drop indexes in the collection using '*', use db.collection.dropIndexes().", errors_1.CommonErrors.InvalidArgument);
|
|
529
530
|
}
|
|
530
|
-
|
|
531
|
-
throw new errors_1.MongoshInvalidInputError('The
|
|
531
|
+
if (Array.isArray(index)) {
|
|
532
|
+
throw new errors_1.MongoshInvalidInputError('The index to drop must be either the index name or the index specification document.', errors_1.CommonErrors.InvalidArgument);
|
|
532
533
|
}
|
|
534
|
+
return this.dropIndexes(index);
|
|
533
535
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
536
|
+
async _getSingleStorageStatValue(key) {
|
|
537
|
+
const cursor = await this.aggregate([
|
|
538
|
+
{ $collStats: { storageStats: {} } },
|
|
539
|
+
{ $group: { _id: null, value: { $sum: `$storageStats.${key}` } } },
|
|
540
|
+
]);
|
|
541
|
+
const [{ value }] = await cursor.toArray();
|
|
542
|
+
return value;
|
|
537
543
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
544
|
+
async totalIndexSize(...args) {
|
|
545
|
+
this._emitCollectionApiCall('totalIndexSize');
|
|
546
|
+
if (args.length) {
|
|
547
|
+
throw new errors_1.MongoshInvalidInputError('"totalIndexSize" takes no argument. Use db.collection.stats to get detailed information.', errors_1.CommonErrors.InvalidArgument);
|
|
542
548
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
549
|
+
return this._getSingleStorageStatValue('totalIndexSize');
|
|
550
|
+
}
|
|
551
|
+
async reIndex() {
|
|
552
|
+
this._emitCollectionApiCall('reIndex');
|
|
553
|
+
return await this._database._runCommand({
|
|
554
|
+
reIndex: this._name,
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
getDB() {
|
|
558
|
+
this._emitCollectionApiCall('getDB');
|
|
559
|
+
return this._database;
|
|
560
|
+
}
|
|
561
|
+
getMongo() {
|
|
562
|
+
this._emitCollectionApiCall('getMongo');
|
|
563
|
+
return this._mongo;
|
|
564
|
+
}
|
|
565
|
+
async dataSize() {
|
|
566
|
+
this._emitCollectionApiCall('dataSize');
|
|
567
|
+
return this._getSingleStorageStatValue('size');
|
|
568
|
+
}
|
|
569
|
+
async storageSize() {
|
|
570
|
+
this._emitCollectionApiCall('storageSize');
|
|
571
|
+
return this._getSingleStorageStatValue('storageSize');
|
|
572
|
+
}
|
|
573
|
+
async totalSize() {
|
|
574
|
+
this._emitCollectionApiCall('totalSize');
|
|
575
|
+
return this._getSingleStorageStatValue('totalSize');
|
|
576
|
+
}
|
|
577
|
+
async drop(options = {}) {
|
|
578
|
+
var _a, _b, _c;
|
|
579
|
+
this._emitCollectionApiCall('drop');
|
|
580
|
+
let encryptedFieldsOptions = {};
|
|
581
|
+
const encryptedFieldsMap = (_a = this._mongo._fleOptions) === null || _a === void 0 ? void 0 : _a.encryptedFieldsMap;
|
|
582
|
+
const encryptedFields = encryptedFieldsMap === null || encryptedFieldsMap === void 0 ? void 0 : encryptedFieldsMap[`${this._database._name}.${this._name}`];
|
|
583
|
+
if (!encryptedFields && !options.encryptedFields) {
|
|
584
|
+
try {
|
|
585
|
+
const collectionInfos = await this._mongo._serviceProvider.listCollections(this._database._name, {
|
|
586
|
+
name: this._name,
|
|
587
|
+
}, await this._database._baseOptions());
|
|
588
|
+
const encryptedFields = (_c = (_b = collectionInfos === null || collectionInfos === void 0 ? void 0 : collectionInfos[0]) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.encryptedFields;
|
|
589
|
+
if (encryptedFields) {
|
|
590
|
+
encryptedFieldsOptions = { encryptedFields };
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
try {
|
|
597
|
+
return await this._mongo._serviceProvider.dropCollection(this._database._name, this._name, {
|
|
598
|
+
...(await this._database._baseOptions()),
|
|
599
|
+
...options,
|
|
600
|
+
...encryptedFieldsOptions,
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
catch (error) {
|
|
604
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'NamespaceNotFound') {
|
|
605
|
+
this._mongo._instanceState.messageBus.emit('mongosh:warn', {
|
|
606
|
+
method: 'drop',
|
|
607
|
+
class: 'Collection',
|
|
608
|
+
message: `Namespace not found: ${this._name}`,
|
|
609
|
+
});
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
async exists() {
|
|
616
|
+
this._emitCollectionApiCall('exists');
|
|
617
|
+
const collectionInfos = await this._mongo._serviceProvider.listCollections(this._database._name, {
|
|
618
|
+
name: this._name,
|
|
619
|
+
}, await this._database._baseOptions());
|
|
620
|
+
return collectionInfos[0] || null;
|
|
621
|
+
}
|
|
622
|
+
getFullName() {
|
|
623
|
+
this._emitCollectionApiCall('getFullName');
|
|
624
|
+
return `${this._database._name}.${this._name}`;
|
|
625
|
+
}
|
|
626
|
+
getName() {
|
|
627
|
+
this._emitCollectionApiCall('getName');
|
|
628
|
+
return `${this._name}`;
|
|
629
|
+
}
|
|
630
|
+
async runCommand(commandName, options) {
|
|
631
|
+
(0, helpers_1.assertArgsDefinedType)([commandName], [['string', 'object']], 'Collection.runCommand');
|
|
632
|
+
if (options) {
|
|
633
|
+
if (typeof commandName !== 'string') {
|
|
634
|
+
throw new errors_1.MongoshInvalidInputError('Collection.runCommand takes a command string as its first arugment', errors_1.CommonErrors.InvalidArgument);
|
|
582
635
|
}
|
|
583
|
-
if (
|
|
584
|
-
'
|
|
585
|
-
'capped',
|
|
586
|
-
'max',
|
|
587
|
-
'paddingFactorNote',
|
|
588
|
-
'indexDetails',
|
|
589
|
-
'wiredTiger',
|
|
590
|
-
].includes(fieldName)) {
|
|
591
|
-
(_a = result[fieldName]) !== null && _a !== void 0 ? _a : (result[fieldName] = shardStorageStats[fieldName]);
|
|
636
|
+
else if (commandName in options) {
|
|
637
|
+
throw new errors_1.MongoshInvalidInputError('The "commandName" argument cannot be passed as an option to "runCommand".', errors_1.CommonErrors.InvalidArgument);
|
|
592
638
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
639
|
+
}
|
|
640
|
+
const hiddenCommands = new RegExp(history_1.HIDDEN_COMMANDS);
|
|
641
|
+
if (typeof commandName === 'string' && !hiddenCommands.test(commandName)) {
|
|
642
|
+
this._emitCollectionApiCall('runCommand', { commandName });
|
|
643
|
+
}
|
|
644
|
+
const cmd = typeof commandName === 'string'
|
|
645
|
+
? {
|
|
646
|
+
[commandName]: this._name,
|
|
647
|
+
...options,
|
|
648
|
+
}
|
|
649
|
+
: commandName;
|
|
650
|
+
return await this._database._runCommand(cmd);
|
|
651
|
+
}
|
|
652
|
+
explain(verbosity = 'queryPlanner') {
|
|
653
|
+
verbosity = (0, helpers_1.validateExplainableVerbosity)(verbosity);
|
|
654
|
+
this._emitCollectionApiCall('explain', { verbosity });
|
|
655
|
+
return new index_1.Explainable(this._mongo, this, verbosity);
|
|
656
|
+
}
|
|
657
|
+
async _getLegacyCollStats(scale) {
|
|
658
|
+
const result = await this._database._runReadCommand({
|
|
659
|
+
collStats: this._name,
|
|
660
|
+
scale: scale || 1,
|
|
661
|
+
});
|
|
662
|
+
if (!result) {
|
|
663
|
+
throw new errors_1.MongoshRuntimeError(`Error running collStats command on ${this.getFullName()}`, errors_1.CommonErrors.CommandFailed);
|
|
664
|
+
}
|
|
665
|
+
return result;
|
|
666
|
+
}
|
|
667
|
+
async _aggregateAndScaleCollStats(collStats, scale) {
|
|
668
|
+
var _a;
|
|
669
|
+
const result = {
|
|
670
|
+
ok: 1,
|
|
671
|
+
};
|
|
672
|
+
const shardStats = {};
|
|
673
|
+
const counts = {};
|
|
674
|
+
const indexSizes = {};
|
|
675
|
+
const clusterTimeseriesStats = {};
|
|
676
|
+
let maxSize = 0;
|
|
677
|
+
let unscaledCollSize = 0;
|
|
678
|
+
let nindexes = 0;
|
|
679
|
+
let timeseriesBucketsNs;
|
|
680
|
+
let timeseriesTotalBucketSize = 0;
|
|
681
|
+
for (const shardResult of collStats) {
|
|
682
|
+
const shardStorageStats = shardResult.storageStats;
|
|
683
|
+
const countField = shardStorageStats.count;
|
|
684
|
+
const shardObjCount = typeof countField !== 'undefined' ? countField : 0;
|
|
685
|
+
for (const fieldName of Object.keys(shardStorageStats)) {
|
|
686
|
+
if (['ns', 'ok', 'lastExtentSize', 'paddingFactor'].includes(fieldName)) {
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
if ([
|
|
690
|
+
'userFlags',
|
|
691
|
+
'capped',
|
|
692
|
+
'max',
|
|
693
|
+
'paddingFactorNote',
|
|
694
|
+
'indexDetails',
|
|
695
|
+
'wiredTiger',
|
|
696
|
+
].includes(fieldName)) {
|
|
697
|
+
(_a = result[fieldName]) !== null && _a !== void 0 ? _a : (result[fieldName] = shardStorageStats[fieldName]);
|
|
698
|
+
}
|
|
699
|
+
else if (fieldName === 'timeseries') {
|
|
700
|
+
const shardTimeseriesStats = shardStorageStats[fieldName];
|
|
701
|
+
for (const [timeseriesStatName, timeseriesStat] of Object.entries(shardTimeseriesStats)) {
|
|
702
|
+
if (typeof timeseriesStat === 'string') {
|
|
703
|
+
if (!timeseriesBucketsNs) {
|
|
704
|
+
timeseriesBucketsNs = timeseriesStat;
|
|
705
|
+
}
|
|
599
706
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
707
|
+
else if (timeseriesStatName === 'avgBucketSize') {
|
|
708
|
+
timeseriesTotalBucketSize +=
|
|
709
|
+
(0, helpers_1.coerceToJSNumber)(shardTimeseriesStats.bucketCount) *
|
|
710
|
+
(0, helpers_1.coerceToJSNumber)(timeseriesStat);
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
if (clusterTimeseriesStats[timeseriesStatName] === undefined) {
|
|
714
|
+
clusterTimeseriesStats[timeseriesStatName] = 0;
|
|
715
|
+
}
|
|
716
|
+
clusterTimeseriesStats[timeseriesStatName] +=
|
|
604
717
|
(0, helpers_1.coerceToJSNumber)(timeseriesStat);
|
|
718
|
+
}
|
|
605
719
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
720
|
+
}
|
|
721
|
+
else if ([
|
|
722
|
+
'count',
|
|
723
|
+
'size',
|
|
724
|
+
'storageSize',
|
|
725
|
+
'totalIndexSize',
|
|
726
|
+
'totalSize',
|
|
727
|
+
'numOrphanDocs',
|
|
728
|
+
].includes(fieldName)) {
|
|
729
|
+
if (counts[fieldName] === undefined) {
|
|
730
|
+
counts[fieldName] = 0;
|
|
731
|
+
}
|
|
732
|
+
counts[fieldName] += (0, helpers_1.coerceToJSNumber)(shardStorageStats[fieldName]);
|
|
733
|
+
}
|
|
734
|
+
else if (fieldName === 'avgObjSize') {
|
|
735
|
+
const shardAvgObjSize = (0, helpers_1.coerceToJSNumber)(shardStorageStats[fieldName]);
|
|
736
|
+
unscaledCollSize += shardAvgObjSize * shardObjCount;
|
|
737
|
+
}
|
|
738
|
+
else if (fieldName === 'maxSize') {
|
|
739
|
+
const shardMaxSize = (0, helpers_1.coerceToJSNumber)(shardStorageStats[fieldName]);
|
|
740
|
+
maxSize = Math.max(maxSize, shardMaxSize);
|
|
741
|
+
}
|
|
742
|
+
else if (fieldName === 'indexSizes') {
|
|
743
|
+
for (const indexName of Object.keys(shardStorageStats[fieldName])) {
|
|
744
|
+
if (indexSizes[indexName] === undefined) {
|
|
745
|
+
indexSizes[indexName] = 0;
|
|
609
746
|
}
|
|
610
|
-
|
|
611
|
-
(0, helpers_1.coerceToJSNumber)(timeseriesStat);
|
|
747
|
+
indexSizes[indexName] += (0, helpers_1.coerceToJSNumber)(shardStorageStats[fieldName][indexName]);
|
|
612
748
|
}
|
|
613
749
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
].includes(fieldName)) {
|
|
623
|
-
if (counts[fieldName] === undefined) {
|
|
624
|
-
counts[fieldName] = 0;
|
|
750
|
+
else if (fieldName === 'nindexes') {
|
|
751
|
+
const shardIndexes = shardStorageStats[fieldName];
|
|
752
|
+
if (nindexes === 0) {
|
|
753
|
+
nindexes = shardIndexes;
|
|
754
|
+
}
|
|
755
|
+
else if (shardIndexes > nindexes) {
|
|
756
|
+
nindexes = shardIndexes;
|
|
757
|
+
}
|
|
625
758
|
}
|
|
626
|
-
counts[fieldName] += (0, helpers_1.coerceToJSNumber)(shardStorageStats[fieldName]);
|
|
627
|
-
}
|
|
628
|
-
else if (fieldName === 'avgObjSize') {
|
|
629
|
-
const shardAvgObjSize = (0, helpers_1.coerceToJSNumber)(shardStorageStats[fieldName]);
|
|
630
|
-
unscaledCollSize += shardAvgObjSize * shardObjCount;
|
|
631
759
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
maxSize = Math.max(maxSize, shardMaxSize);
|
|
760
|
+
if (shardResult.shard) {
|
|
761
|
+
shardStats[shardResult.shard] = (0, helpers_1.scaleIndividualShardStatistics)(shardStorageStats, scale);
|
|
635
762
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
763
|
+
}
|
|
764
|
+
const ns = `${this._database._name}.${this._name}`;
|
|
765
|
+
const config = this._mongo.getDB('config');
|
|
766
|
+
if (collStats[0].shard) {
|
|
767
|
+
result.shards = shardStats;
|
|
768
|
+
}
|
|
769
|
+
try {
|
|
770
|
+
result.sharded = !!(await config.getCollection('collections').findOne({
|
|
771
|
+
_id: timeseriesBucketsNs !== null && timeseriesBucketsNs !== void 0 ? timeseriesBucketsNs : ns,
|
|
772
|
+
...helpers_1.onlyShardedCollectionsInConfigFilter,
|
|
773
|
+
}));
|
|
774
|
+
}
|
|
775
|
+
catch (e) {
|
|
776
|
+
result.sharded = collStats.length > 1;
|
|
777
|
+
}
|
|
778
|
+
for (const [countField, count] of Object.entries(counts)) {
|
|
779
|
+
if (['size', 'storageSize', 'totalIndexSize', 'totalSize'].includes(countField)) {
|
|
780
|
+
result[countField] = count / scale;
|
|
643
781
|
}
|
|
644
|
-
else
|
|
645
|
-
|
|
646
|
-
if (nindexes === 0) {
|
|
647
|
-
nindexes = shardIndexes;
|
|
648
|
-
}
|
|
649
|
-
else if (shardIndexes > nindexes) {
|
|
650
|
-
nindexes = shardIndexes;
|
|
651
|
-
}
|
|
782
|
+
else {
|
|
783
|
+
result[countField] = count;
|
|
652
784
|
}
|
|
653
785
|
}
|
|
654
|
-
if (
|
|
655
|
-
|
|
786
|
+
if (timeseriesBucketsNs && Object.keys(clusterTimeseriesStats).length > 0) {
|
|
787
|
+
result.timeseries = {
|
|
788
|
+
...clusterTimeseriesStats,
|
|
789
|
+
avgBucketSize: clusterTimeseriesStats.bucketCount
|
|
790
|
+
? timeseriesTotalBucketSize / clusterTimeseriesStats.bucketCount
|
|
791
|
+
: 0,
|
|
792
|
+
bucketsNs: timeseriesBucketsNs,
|
|
793
|
+
};
|
|
656
794
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
try {
|
|
664
|
-
result.sharded = !!(await config.getCollection('collections').findOne({
|
|
665
|
-
_id: timeseriesBucketsNs !== null && timeseriesBucketsNs !== void 0 ? timeseriesBucketsNs : ns,
|
|
666
|
-
dropped: { $ne: true },
|
|
667
|
-
}));
|
|
668
|
-
}
|
|
669
|
-
catch (e) {
|
|
670
|
-
result.sharded = collStats.length > 1;
|
|
671
|
-
}
|
|
672
|
-
for (const [countField, count] of Object.entries(counts)) {
|
|
673
|
-
if (['size', 'storageSize', 'totalIndexSize', 'totalSize'].includes(countField)) {
|
|
674
|
-
result[countField] = count / scale;
|
|
795
|
+
result.indexSizes = {};
|
|
796
|
+
for (const [indexName, indexSize] of Object.entries(indexSizes)) {
|
|
797
|
+
result.indexSizes[indexName] = indexSize / scale;
|
|
798
|
+
}
|
|
799
|
+
if (counts.count > 0) {
|
|
800
|
+
result.avgObjSize = unscaledCollSize / counts.count;
|
|
675
801
|
}
|
|
676
802
|
else {
|
|
677
|
-
result
|
|
803
|
+
result.avgObjSize = 0;
|
|
678
804
|
}
|
|
805
|
+
if (result.capped) {
|
|
806
|
+
result.maxSize = maxSize / scale;
|
|
807
|
+
}
|
|
808
|
+
result.ns = ns;
|
|
809
|
+
result.nindexes = nindexes;
|
|
810
|
+
if (collStats[0].storageStats.scaleFactor !== undefined) {
|
|
811
|
+
result.scaleFactor = scale;
|
|
812
|
+
}
|
|
813
|
+
result.ok = 1;
|
|
814
|
+
return result;
|
|
679
815
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
result.indexSizes = {};
|
|
690
|
-
for (const [indexName, indexSize] of Object.entries(indexSizes)) {
|
|
691
|
-
result.indexSizes[indexName] = indexSize / scale;
|
|
692
|
-
}
|
|
693
|
-
if (counts.count > 0) {
|
|
694
|
-
result.avgObjSize = unscaledCollSize / counts.count;
|
|
695
|
-
}
|
|
696
|
-
else {
|
|
697
|
-
result.avgObjSize = 0;
|
|
698
|
-
}
|
|
699
|
-
if (result.capped) {
|
|
700
|
-
result.maxSize = maxSize / scale;
|
|
701
|
-
}
|
|
702
|
-
result.ns = ns;
|
|
703
|
-
result.nindexes = nindexes;
|
|
704
|
-
if (collStats[0].storageStats.scaleFactor !== undefined) {
|
|
705
|
-
result.scaleFactor = scale;
|
|
706
|
-
}
|
|
707
|
-
result.ok = 1;
|
|
708
|
-
return result;
|
|
709
|
-
}
|
|
710
|
-
async _getAggregatedCollStats(scale) {
|
|
711
|
-
try {
|
|
712
|
-
const collStats = await (await this.aggregate([
|
|
713
|
-
{
|
|
714
|
-
$collStats: {
|
|
715
|
-
storageStats: {
|
|
716
|
-
scale: 1,
|
|
816
|
+
async _getAggregatedCollStats(scale) {
|
|
817
|
+
try {
|
|
818
|
+
const collStats = await (await this.aggregate([
|
|
819
|
+
{
|
|
820
|
+
$collStats: {
|
|
821
|
+
storageStats: {
|
|
822
|
+
scale: 1,
|
|
823
|
+
},
|
|
717
824
|
},
|
|
718
825
|
},
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
826
|
+
])).toArray();
|
|
827
|
+
if (!collStats || collStats[0] === undefined) {
|
|
828
|
+
throw new errors_1.MongoshRuntimeError(`Error running $collStats aggregation stage on ${this.getFullName()}`, errors_1.CommonErrors.CommandFailed);
|
|
829
|
+
}
|
|
830
|
+
return await this._aggregateAndScaleCollStats(collStats, scale);
|
|
831
|
+
}
|
|
832
|
+
catch (e) {
|
|
833
|
+
if ((e === null || e === void 0 ? void 0 : e.codeName) === 'StaleConfig' || (e === null || e === void 0 ? void 0 : e.code) === 13388) {
|
|
834
|
+
try {
|
|
835
|
+
return await this._getLegacyCollStats(scale);
|
|
836
|
+
}
|
|
837
|
+
catch (legacyCollStatsError) {
|
|
838
|
+
throw e;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
throw e;
|
|
723
842
|
}
|
|
724
|
-
return await this._aggregateAndScaleCollStats(collStats, scale);
|
|
725
843
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
844
|
+
async stats(originalOptions = {}) {
|
|
845
|
+
var _a;
|
|
846
|
+
const options = typeof originalOptions === 'number'
|
|
847
|
+
? { scale: originalOptions }
|
|
848
|
+
: originalOptions;
|
|
849
|
+
if (options.indexDetailsKey && options.indexDetailsName) {
|
|
850
|
+
throw new errors_1.MongoshInvalidInputError('Cannot filter indexDetails on both indexDetailsKey and indexDetailsName', errors_1.CommonErrors.InvalidArgument);
|
|
851
|
+
}
|
|
852
|
+
if (options.indexDetailsKey &&
|
|
853
|
+
typeof options.indexDetailsKey !== 'object') {
|
|
854
|
+
throw new errors_1.MongoshInvalidInputError(`Expected options.indexDetailsKey to be a document, got ${typeof options.indexDetailsKey}`, errors_1.CommonErrors.InvalidArgument);
|
|
855
|
+
}
|
|
856
|
+
if (options.indexDetailsName &&
|
|
857
|
+
typeof options.indexDetailsName !== 'string') {
|
|
858
|
+
throw new errors_1.MongoshInvalidInputError(`Expected options.indexDetailsName to be a string, got ${typeof options.indexDetailsName}`, errors_1.CommonErrors.InvalidArgument);
|
|
859
|
+
}
|
|
860
|
+
options.scale = options.scale || 1;
|
|
861
|
+
options.indexDetails = options.indexDetails || false;
|
|
862
|
+
this._emitCollectionApiCall('stats', { options });
|
|
863
|
+
const result = await this._getAggregatedCollStats(options.scale);
|
|
864
|
+
let filterIndexName = options.indexDetailsName;
|
|
865
|
+
if (!filterIndexName && options.indexDetailsKey) {
|
|
866
|
+
const indexes = await this._mongo._serviceProvider.getIndexes(this._database._name, this._name, await this._database._baseOptions());
|
|
867
|
+
indexes.forEach((spec) => {
|
|
868
|
+
if (JSON.stringify(spec.key) === JSON.stringify(options.indexDetailsKey)) {
|
|
869
|
+
filterIndexName = spec.name;
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
const updateStats = (stats) => {
|
|
874
|
+
if (!stats.indexDetails) {
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
if (!options.indexDetails) {
|
|
878
|
+
delete stats.indexDetails;
|
|
879
|
+
return;
|
|
730
880
|
}
|
|
731
|
-
|
|
732
|
-
|
|
881
|
+
if (!filterIndexName) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
for (const key of Object.keys(stats.indexDetails)) {
|
|
885
|
+
if (key === filterIndexName) {
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
delete stats.indexDetails[key];
|
|
733
889
|
}
|
|
890
|
+
};
|
|
891
|
+
updateStats(result);
|
|
892
|
+
for (const shardName of Object.keys((_a = result.shards) !== null && _a !== void 0 ? _a : {})) {
|
|
893
|
+
updateStats(result.shards[shardName]);
|
|
734
894
|
}
|
|
735
|
-
|
|
895
|
+
return result;
|
|
896
|
+
}
|
|
897
|
+
async latencyStats(options = {}) {
|
|
898
|
+
this._emitCollectionApiCall('latencyStats', { options });
|
|
899
|
+
return await (await this.aggregate([{ $collStats: { latencyStats: options } }])).toArray();
|
|
900
|
+
}
|
|
901
|
+
async initializeOrderedBulkOp() {
|
|
902
|
+
this._emitCollectionApiCall('initializeOrderedBulkOp');
|
|
903
|
+
const innerBulk = await this._mongo._serviceProvider.initializeBulkOp(this._database._name, this._name, true, await this._database._baseOptions());
|
|
904
|
+
return new bulk_1.default(this, innerBulk, true);
|
|
905
|
+
}
|
|
906
|
+
async initializeUnorderedBulkOp() {
|
|
907
|
+
this._emitCollectionApiCall('initializeUnorderedBulkOp');
|
|
908
|
+
const innerBulk = await this._mongo._serviceProvider.initializeBulkOp(this._database._name, this._name, false, await this._database._baseOptions());
|
|
909
|
+
return new bulk_1.default(this, innerBulk);
|
|
910
|
+
}
|
|
911
|
+
getPlanCache() {
|
|
912
|
+
this._emitCollectionApiCall('getPlanCache');
|
|
913
|
+
return new plan_cache_1.default(this);
|
|
914
|
+
}
|
|
915
|
+
async mapReduce(map, reduce, optionsOrOutString) {
|
|
916
|
+
await this._instanceState.printDeprecationWarning('Collection.mapReduce() is deprecated. Use an aggregation instead.\nSee https://docs.mongodb.com/manual/core/map-reduce for details.');
|
|
917
|
+
(0, helpers_1.assertArgsDefinedType)([map, reduce, optionsOrOutString], [true, true, true], 'Collection.mapReduce');
|
|
918
|
+
this._emitCollectionApiCall('mapReduce', {
|
|
919
|
+
map,
|
|
920
|
+
reduce,
|
|
921
|
+
out: optionsOrOutString,
|
|
922
|
+
});
|
|
923
|
+
let cmd = {
|
|
924
|
+
mapReduce: this._name,
|
|
925
|
+
map: map,
|
|
926
|
+
reduce: reduce,
|
|
927
|
+
...(0, helpers_1.processMapReduceOptions)(optionsOrOutString),
|
|
928
|
+
};
|
|
929
|
+
if (cmd.explain) {
|
|
930
|
+
const verbosity = cmd.explain;
|
|
931
|
+
delete cmd.explain;
|
|
932
|
+
cmd = {
|
|
933
|
+
explain: cmd,
|
|
934
|
+
verbosity,
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
return await this._database._runCommand(cmd);
|
|
736
938
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}
|
|
746
|
-
if (options.indexDetailsKey &&
|
|
747
|
-
typeof options.indexDetailsKey !== 'object') {
|
|
748
|
-
throw new errors_1.MongoshInvalidInputError(`Expected options.indexDetailsKey to be a document, got ${typeof options.indexDetailsKey}`, errors_1.CommonErrors.InvalidArgument);
|
|
749
|
-
}
|
|
750
|
-
if (options.indexDetailsName &&
|
|
751
|
-
typeof options.indexDetailsName !== 'string') {
|
|
752
|
-
throw new errors_1.MongoshInvalidInputError(`Expected options.indexDetailsName to be a string, got ${typeof options.indexDetailsName}`, errors_1.CommonErrors.InvalidArgument);
|
|
753
|
-
}
|
|
754
|
-
options.scale = options.scale || 1;
|
|
755
|
-
options.indexDetails = options.indexDetails || false;
|
|
756
|
-
this._emitCollectionApiCall('stats', { options });
|
|
757
|
-
const result = await this._getAggregatedCollStats(options.scale);
|
|
758
|
-
let filterIndexName = options.indexDetailsName;
|
|
759
|
-
if (!filterIndexName && options.indexDetailsKey) {
|
|
760
|
-
const indexes = await this._mongo._serviceProvider.getIndexes(this._database._name, this._name, await this._database._baseOptions());
|
|
761
|
-
indexes.forEach((spec) => {
|
|
762
|
-
if (JSON.stringify(spec.key) === JSON.stringify(options.indexDetailsKey)) {
|
|
763
|
-
filterIndexName = spec.name;
|
|
764
|
-
}
|
|
939
|
+
async validate(options = false) {
|
|
940
|
+
this._emitCollectionApiCall('validate', { options });
|
|
941
|
+
if (typeof options === 'boolean') {
|
|
942
|
+
options = { full: options };
|
|
943
|
+
}
|
|
944
|
+
return await this._database._runReadCommand({
|
|
945
|
+
validate: this._name,
|
|
946
|
+
...options,
|
|
765
947
|
});
|
|
766
948
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
949
|
+
async getShardVersion() {
|
|
950
|
+
this._emitCollectionApiCall('getShardVersion', {});
|
|
951
|
+
return await this._database._runAdminCommand({
|
|
952
|
+
getShardVersion: `${this._database._name}.${this._name}`,
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
async getShardDistribution() {
|
|
956
|
+
this._emitCollectionApiCall('getShardDistribution', {});
|
|
957
|
+
const result = {};
|
|
958
|
+
const config = this._mongo.getDB('config');
|
|
959
|
+
const ns = `${this._database._name}.${this._name}`;
|
|
960
|
+
const configCollectionsInfo = await config
|
|
961
|
+
.getCollection('collections')
|
|
962
|
+
.findOne({
|
|
963
|
+
_id: ns,
|
|
964
|
+
...helpers_1.onlyShardedCollectionsInConfigFilter,
|
|
965
|
+
});
|
|
966
|
+
if (!configCollectionsInfo) {
|
|
967
|
+
throw new errors_1.MongoshInvalidInputError(`Collection ${this._name} is not sharded`, error_codes_1.ShellApiErrors.NotConnectedToShardedCluster);
|
|
770
968
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
969
|
+
const collStats = await (await this.aggregate({ $collStats: { storageStats: {} } })).toArray();
|
|
970
|
+
const totals = { numChunks: 0, size: 0, count: 0 };
|
|
971
|
+
const conciseShardsStats = [];
|
|
972
|
+
await Promise.all(collStats.map((extShardStats) => (async () => {
|
|
973
|
+
const { shard } = extShardStats;
|
|
974
|
+
const countChunksQuery = {
|
|
975
|
+
...(0, helpers_1.buildConfigChunksCollectionMatch)(configCollectionsInfo),
|
|
976
|
+
shard,
|
|
977
|
+
};
|
|
978
|
+
const [host, numChunks] = await Promise.all([
|
|
979
|
+
config
|
|
980
|
+
.getCollection('shards')
|
|
981
|
+
.findOne({ _id: extShardStats.shard }),
|
|
982
|
+
config.getCollection('chunks').countDocuments(countChunksQuery),
|
|
983
|
+
]);
|
|
984
|
+
const shardStats = {
|
|
985
|
+
shardId: shard,
|
|
986
|
+
host: host !== null ? host.host : null,
|
|
987
|
+
size: extShardStats.storageStats.size,
|
|
988
|
+
count: extShardStats.storageStats.count,
|
|
989
|
+
numChunks: numChunks,
|
|
990
|
+
avgObjSize: extShardStats.storageStats.avgObjSize,
|
|
991
|
+
};
|
|
992
|
+
const key = `Shard ${shardStats.shardId} at ${shardStats.host}`;
|
|
993
|
+
const estChunkData = shardStats.numChunks === 0
|
|
994
|
+
? 0
|
|
995
|
+
: shardStats.size / shardStats.numChunks;
|
|
996
|
+
const estChunkCount = shardStats.numChunks === 0
|
|
997
|
+
? 0
|
|
998
|
+
: Math.floor(shardStats.count / shardStats.numChunks);
|
|
999
|
+
result[key] = {
|
|
1000
|
+
data: (0, helpers_1.dataFormat)((0, helpers_1.coerceToJSNumber)(shardStats.size)),
|
|
1001
|
+
docs: shardStats.count,
|
|
1002
|
+
chunks: shardStats.numChunks,
|
|
1003
|
+
'estimated data per chunk': (0, helpers_1.dataFormat)(estChunkData),
|
|
1004
|
+
'estimated docs per chunk': estChunkCount,
|
|
1005
|
+
};
|
|
1006
|
+
totals.size += (0, helpers_1.coerceToJSNumber)(shardStats.size);
|
|
1007
|
+
totals.count += (0, helpers_1.coerceToJSNumber)(shardStats.count);
|
|
1008
|
+
totals.numChunks += (0, helpers_1.coerceToJSNumber)(shardStats.numChunks);
|
|
1009
|
+
conciseShardsStats.push(shardStats);
|
|
1010
|
+
})()));
|
|
1011
|
+
const totalValue = {
|
|
1012
|
+
data: (0, helpers_1.dataFormat)(totals.size),
|
|
1013
|
+
docs: totals.count,
|
|
1014
|
+
chunks: totals.numChunks,
|
|
1015
|
+
};
|
|
1016
|
+
for (const shardStats of conciseShardsStats) {
|
|
1017
|
+
const estDataPercent = totals.size === 0
|
|
1018
|
+
? 0
|
|
1019
|
+
: Math.floor((shardStats.size / totals.size) * 10000) / 100;
|
|
1020
|
+
const estDocPercent = totals.count === 0
|
|
1021
|
+
? 0
|
|
1022
|
+
: Math.floor((shardStats.count / totals.count) * 10000) / 100;
|
|
1023
|
+
totalValue[`Shard ${shardStats.shardId}`] = [
|
|
1024
|
+
`${estDataPercent} % data`,
|
|
1025
|
+
`${estDocPercent} % docs in cluster`,
|
|
1026
|
+
`${(0, helpers_1.dataFormat)(shardStats.avgObjSize)} avg obj size on shard`,
|
|
1027
|
+
];
|
|
774
1028
|
}
|
|
775
|
-
|
|
776
|
-
|
|
1029
|
+
result.Totals = totalValue;
|
|
1030
|
+
return new index_1.CommandResult('StatsResult', result);
|
|
1031
|
+
}
|
|
1032
|
+
async watch(pipeline = [], options = {}) {
|
|
1033
|
+
if (!Array.isArray(pipeline)) {
|
|
1034
|
+
options = pipeline;
|
|
1035
|
+
pipeline = [];
|
|
777
1036
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
1037
|
+
this._emitCollectionApiCall('watch', { pipeline, options });
|
|
1038
|
+
const cursor = new change_stream_cursor_1.default(this._mongo._serviceProvider.watch(pipeline, {
|
|
1039
|
+
...(await this._database._baseOptions()),
|
|
1040
|
+
...options,
|
|
1041
|
+
}, {}, this._database._name, this._name), this._name, this._mongo);
|
|
1042
|
+
if (!options.resumeAfter &&
|
|
1043
|
+
!options.startAfter &&
|
|
1044
|
+
!options.startAtOperationTime) {
|
|
1045
|
+
await cursor.tryNext();
|
|
783
1046
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
1047
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
1048
|
+
return cursor;
|
|
1049
|
+
}
|
|
1050
|
+
async hideIndex(index) {
|
|
1051
|
+
this._emitCollectionApiCall('hideIndex');
|
|
1052
|
+
return (0, helpers_1.setHideIndex)(this, index, true);
|
|
1053
|
+
}
|
|
1054
|
+
async unhideIndex(index) {
|
|
1055
|
+
this._emitCollectionApiCall('unhideIndex');
|
|
1056
|
+
return (0, helpers_1.setHideIndex)(this, index, false);
|
|
1057
|
+
}
|
|
1058
|
+
async analyzeShardKey(key, options = {}) {
|
|
1059
|
+
(0, helpers_1.assertArgsDefinedType)([key], [true], 'Collection.analyzeShardKey');
|
|
1060
|
+
this._emitCollectionApiCall('analyzeShardKey', { key });
|
|
1061
|
+
return await this._database._runAdminCommand({
|
|
1062
|
+
analyzeShardKey: this.getFullName(),
|
|
1063
|
+
key,
|
|
1064
|
+
...options,
|
|
1065
|
+
});
|
|
788
1066
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
async initializeOrderedBulkOp() {
|
|
796
|
-
this._emitCollectionApiCall('initializeOrderedBulkOp');
|
|
797
|
-
const innerBulk = await this._mongo._serviceProvider.initializeBulkOp(this._database._name, this._name, true, await this._database._baseOptions());
|
|
798
|
-
return new bulk_1.default(this, innerBulk, true);
|
|
799
|
-
}
|
|
800
|
-
async initializeUnorderedBulkOp() {
|
|
801
|
-
this._emitCollectionApiCall('initializeUnorderedBulkOp');
|
|
802
|
-
const innerBulk = await this._mongo._serviceProvider.initializeBulkOp(this._database._name, this._name, false, await this._database._baseOptions());
|
|
803
|
-
return new bulk_1.default(this, innerBulk);
|
|
804
|
-
}
|
|
805
|
-
getPlanCache() {
|
|
806
|
-
this._emitCollectionApiCall('getPlanCache');
|
|
807
|
-
return new plan_cache_1.default(this);
|
|
808
|
-
}
|
|
809
|
-
async mapReduce(map, reduce, optionsOrOutString) {
|
|
810
|
-
await this._instanceState.printDeprecationWarning('Collection.mapReduce() is deprecated. Use an aggregation instead.\nSee https://docs.mongodb.com/manual/core/map-reduce for details.');
|
|
811
|
-
(0, helpers_1.assertArgsDefinedType)([map, reduce, optionsOrOutString], [true, true, true], 'Collection.mapReduce');
|
|
812
|
-
this._emitCollectionApiCall('mapReduce', {
|
|
813
|
-
map,
|
|
814
|
-
reduce,
|
|
815
|
-
out: optionsOrOutString,
|
|
816
|
-
});
|
|
817
|
-
let cmd = {
|
|
818
|
-
mapReduce: this._name,
|
|
819
|
-
map: map,
|
|
820
|
-
reduce: reduce,
|
|
821
|
-
...(0, helpers_1.processMapReduceOptions)(optionsOrOutString),
|
|
822
|
-
};
|
|
823
|
-
if (cmd.explain) {
|
|
824
|
-
const verbosity = cmd.explain;
|
|
825
|
-
delete cmd.explain;
|
|
826
|
-
cmd = {
|
|
827
|
-
explain: cmd,
|
|
828
|
-
verbosity,
|
|
829
|
-
};
|
|
1067
|
+
async configureQueryAnalyzer(options) {
|
|
1068
|
+
this._emitCollectionApiCall('configureQueryAnalyzer', options);
|
|
1069
|
+
return await this._database._runAdminCommand({
|
|
1070
|
+
configureQueryAnalyzer: this.getFullName(),
|
|
1071
|
+
...options,
|
|
1072
|
+
});
|
|
830
1073
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
options = { full: options };
|
|
837
|
-
}
|
|
838
|
-
return await this._database._runReadCommand({
|
|
839
|
-
validate: this._name,
|
|
840
|
-
...options,
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
async getShardVersion() {
|
|
844
|
-
this._emitCollectionApiCall('getShardVersion', {});
|
|
845
|
-
return await this._database._runAdminCommand({
|
|
846
|
-
getShardVersion: `${this._database._name}.${this._name}`,
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
async getShardDistribution() {
|
|
850
|
-
this._emitCollectionApiCall('getShardDistribution', {});
|
|
851
|
-
const result = {};
|
|
852
|
-
const config = this._mongo.getDB('config');
|
|
853
|
-
const ns = `${this._database._name}.${this._name}`;
|
|
854
|
-
const configCollectionsInfo = await config
|
|
855
|
-
.getCollection('collections')
|
|
856
|
-
.findOne({
|
|
857
|
-
_id: ns,
|
|
858
|
-
dropped: { $ne: true },
|
|
859
|
-
});
|
|
860
|
-
if (!configCollectionsInfo) {
|
|
861
|
-
throw new errors_1.MongoshInvalidInputError(`Collection ${this._name} is not sharded`, error_codes_1.ShellApiErrors.NotConnectedToShardedCluster);
|
|
862
|
-
}
|
|
863
|
-
const collStats = await (await this.aggregate({ $collStats: { storageStats: {} } })).toArray();
|
|
864
|
-
const totals = { numChunks: 0, size: 0, count: 0 };
|
|
865
|
-
const conciseShardsStats = [];
|
|
866
|
-
await Promise.all(collStats.map((extShardStats) => (async () => {
|
|
867
|
-
const { shard } = extShardStats;
|
|
868
|
-
const countChunksQuery = {
|
|
869
|
-
...(0, helpers_1.buildConfigChunksCollectionMatch)(configCollectionsInfo),
|
|
870
|
-
shard,
|
|
871
|
-
};
|
|
872
|
-
const [host, numChunks] = await Promise.all([
|
|
873
|
-
config
|
|
874
|
-
.getCollection('shards')
|
|
875
|
-
.findOne({ _id: extShardStats.shard }),
|
|
876
|
-
config.getCollection('chunks').countDocuments(countChunksQuery),
|
|
877
|
-
]);
|
|
878
|
-
const shardStats = {
|
|
879
|
-
shardId: shard,
|
|
880
|
-
host: host !== null ? host.host : null,
|
|
881
|
-
size: extShardStats.storageStats.size,
|
|
882
|
-
count: extShardStats.storageStats.count,
|
|
883
|
-
numChunks: numChunks,
|
|
884
|
-
avgObjSize: extShardStats.storageStats.avgObjSize,
|
|
885
|
-
};
|
|
886
|
-
const key = `Shard ${shardStats.shardId} at ${shardStats.host}`;
|
|
887
|
-
const estChunkData = shardStats.numChunks === 0
|
|
888
|
-
? 0
|
|
889
|
-
: shardStats.size / shardStats.numChunks;
|
|
890
|
-
const estChunkCount = shardStats.numChunks === 0
|
|
891
|
-
? 0
|
|
892
|
-
: Math.floor(shardStats.count / shardStats.numChunks);
|
|
893
|
-
result[key] = {
|
|
894
|
-
data: (0, helpers_1.dataFormat)((0, helpers_1.coerceToJSNumber)(shardStats.size)),
|
|
895
|
-
docs: shardStats.count,
|
|
896
|
-
chunks: shardStats.numChunks,
|
|
897
|
-
'estimated data per chunk': (0, helpers_1.dataFormat)(estChunkData),
|
|
898
|
-
'estimated docs per chunk': estChunkCount,
|
|
899
|
-
};
|
|
900
|
-
totals.size += (0, helpers_1.coerceToJSNumber)(shardStats.size);
|
|
901
|
-
totals.count += (0, helpers_1.coerceToJSNumber)(shardStats.count);
|
|
902
|
-
totals.numChunks += (0, helpers_1.coerceToJSNumber)(shardStats.numChunks);
|
|
903
|
-
conciseShardsStats.push(shardStats);
|
|
904
|
-
})()));
|
|
905
|
-
const totalValue = {
|
|
906
|
-
data: (0, helpers_1.dataFormat)(totals.size),
|
|
907
|
-
docs: totals.count,
|
|
908
|
-
chunks: totals.numChunks,
|
|
909
|
-
};
|
|
910
|
-
for (const shardStats of conciseShardsStats) {
|
|
911
|
-
const estDataPercent = totals.size === 0
|
|
912
|
-
? 0
|
|
913
|
-
: Math.floor((shardStats.size / totals.size) * 10000) / 100;
|
|
914
|
-
const estDocPercent = totals.count === 0
|
|
915
|
-
? 0
|
|
916
|
-
: Math.floor((shardStats.count / totals.count) * 10000) / 100;
|
|
917
|
-
totalValue[`Shard ${shardStats.shardId}`] = [
|
|
918
|
-
`${estDataPercent} % data`,
|
|
919
|
-
`${estDocPercent} % docs in cluster`,
|
|
920
|
-
`${(0, helpers_1.dataFormat)(shardStats.avgObjSize)} avg obj size on shard`,
|
|
921
|
-
];
|
|
922
|
-
}
|
|
923
|
-
result.Totals = totalValue;
|
|
924
|
-
return new index_1.CommandResult('StatsResult', result);
|
|
925
|
-
}
|
|
926
|
-
async watch(pipeline = [], options = {}) {
|
|
927
|
-
if (!Array.isArray(pipeline)) {
|
|
928
|
-
options = pipeline;
|
|
929
|
-
pipeline = [];
|
|
930
|
-
}
|
|
931
|
-
this._emitCollectionApiCall('watch', { pipeline, options });
|
|
932
|
-
const cursor = new change_stream_cursor_1.default(this._mongo._serviceProvider.watch(pipeline, {
|
|
933
|
-
...(await this._database._baseOptions()),
|
|
934
|
-
...options,
|
|
935
|
-
}, {}, this._database._name, this._name), this._name, this._mongo);
|
|
936
|
-
if (!options.resumeAfter &&
|
|
937
|
-
!options.startAfter &&
|
|
938
|
-
!options.startAtOperationTime) {
|
|
939
|
-
await cursor.tryNext();
|
|
940
|
-
}
|
|
941
|
-
this._mongo._instanceState.currentCursor = cursor;
|
|
942
|
-
return cursor;
|
|
943
|
-
}
|
|
944
|
-
async hideIndex(index) {
|
|
945
|
-
this._emitCollectionApiCall('hideIndex');
|
|
946
|
-
return (0, helpers_1.setHideIndex)(this, index, true);
|
|
947
|
-
}
|
|
948
|
-
async unhideIndex(index) {
|
|
949
|
-
this._emitCollectionApiCall('unhideIndex');
|
|
950
|
-
return (0, helpers_1.setHideIndex)(this, index, false);
|
|
951
|
-
}
|
|
952
|
-
async analyzeShardKey(key, options = {}) {
|
|
953
|
-
(0, helpers_1.assertArgsDefinedType)([key], [true], 'Collection.analyzeShardKey');
|
|
954
|
-
this._emitCollectionApiCall('analyzeShardKey', { key });
|
|
955
|
-
return await this._database._runAdminCommand({
|
|
956
|
-
analyzeShardKey: this.getFullName(),
|
|
957
|
-
key,
|
|
958
|
-
...options,
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
async configureQueryAnalyzer(options) {
|
|
962
|
-
this._emitCollectionApiCall('configureQueryAnalyzer', options);
|
|
963
|
-
return await this._database._runAdminCommand({
|
|
964
|
-
configureQueryAnalyzer: this.getFullName(),
|
|
965
|
-
...options,
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
async checkMetadataConsistency(options = {}) {
|
|
969
|
-
this._emitCollectionApiCall('checkMetadataConsistency', { options });
|
|
970
|
-
return this._database._runCursorCommand({
|
|
971
|
-
checkMetadataConsistency: this._name,
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
async getSearchIndexes(indexName, options) {
|
|
975
|
-
if (typeof indexName === 'object' && indexName !== null) {
|
|
976
|
-
options = indexName;
|
|
977
|
-
indexName = undefined;
|
|
1074
|
+
async checkMetadataConsistency(options = {}) {
|
|
1075
|
+
this._emitCollectionApiCall('checkMetadataConsistency', { options });
|
|
1076
|
+
return this._database._runCursorCommand({
|
|
1077
|
+
checkMetadataConsistency: this._name,
|
|
1078
|
+
});
|
|
978
1079
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1080
|
+
async getSearchIndexes(indexName, options) {
|
|
1081
|
+
if (typeof indexName === 'object' && indexName !== null) {
|
|
1082
|
+
options = indexName;
|
|
1083
|
+
indexName = undefined;
|
|
1084
|
+
}
|
|
1085
|
+
this._emitCollectionApiCall('getSearchIndexes', { options });
|
|
1086
|
+
return await this._mongo._serviceProvider.getSearchIndexes(this._database._name, this._name, indexName, { ...(await this._database._baseOptions()), ...options });
|
|
1087
|
+
}
|
|
1088
|
+
async createSearchIndex(indexName, type, definition) {
|
|
1089
|
+
var _a;
|
|
1090
|
+
if (typeof type === 'object' && type !== null) {
|
|
1091
|
+
definition = type;
|
|
1092
|
+
type = undefined;
|
|
1093
|
+
}
|
|
1094
|
+
if (typeof indexName === 'object' && indexName !== null) {
|
|
1095
|
+
definition = indexName;
|
|
1096
|
+
indexName = undefined;
|
|
1097
|
+
}
|
|
1098
|
+
this._emitCollectionApiCall('createSearchIndex', { indexName, definition });
|
|
1099
|
+
const results = await this._mongo._serviceProvider.createSearchIndexes(this._database._name, this._name, [
|
|
1100
|
+
{
|
|
1101
|
+
name: (_a = indexName) !== null && _a !== void 0 ? _a : 'default',
|
|
1102
|
+
...(type &&
|
|
1103
|
+
type !== 'search' && { type: type }),
|
|
1104
|
+
definition: { ...definition },
|
|
1105
|
+
},
|
|
1106
|
+
]);
|
|
1107
|
+
return results[0];
|
|
1108
|
+
}
|
|
1109
|
+
async createSearchIndexes(specs) {
|
|
1110
|
+
this._emitCollectionApiCall('createSearchIndexes', { specs });
|
|
1111
|
+
return await this._mongo._serviceProvider.createSearchIndexes(this._database._name, this._name, specs.map(({ type, ...spec }) => ({
|
|
1112
|
+
...spec,
|
|
1113
|
+
...(type && type !== 'search' && { type }),
|
|
1114
|
+
})));
|
|
1115
|
+
}
|
|
1116
|
+
async dropSearchIndex(indexName) {
|
|
1117
|
+
this._emitCollectionApiCall('dropSearchIndex', { indexName });
|
|
1118
|
+
return await this._mongo._serviceProvider.dropSearchIndex(this._database._name, this._name, indexName);
|
|
1119
|
+
}
|
|
1120
|
+
async updateSearchIndex(indexName, definition) {
|
|
1121
|
+
this._emitCollectionApiCall('updateSearchIndex', { indexName, definition });
|
|
1122
|
+
return await this._mongo._serviceProvider.updateSearchIndex(this._database._name, this._name, indexName, definition);
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
__setFunctionName(_classThis, "Collection");
|
|
1126
|
+
(() => {
|
|
983
1127
|
var _a;
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
]);
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
],
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
],
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
(0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
|
|
1125
|
-
(0, decorators_1.apiVersions)([1])
|
|
1126
|
-
], Collection.prototype, "updateMany", null);
|
|
1127
|
-
__decorate([
|
|
1128
|
-
decorators_1.returnsPromise,
|
|
1129
|
-
(0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
|
|
1130
|
-
(0, decorators_1.apiVersions)([1])
|
|
1131
|
-
], Collection.prototype, "updateOne", null);
|
|
1132
|
-
__decorate([
|
|
1133
|
-
decorators_1.returnsPromise,
|
|
1134
|
-
(0, decorators_1.apiVersions)([])
|
|
1135
|
-
], Collection.prototype, "compactStructuredEncryptionData", null);
|
|
1136
|
-
__decorate([
|
|
1137
|
-
decorators_1.returnsPromise,
|
|
1138
|
-
(0, decorators_1.apiVersions)([])
|
|
1139
|
-
], Collection.prototype, "convertToCapped", null);
|
|
1140
|
-
__decorate([
|
|
1141
|
-
decorators_1.returnsPromise,
|
|
1142
|
-
(0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
|
|
1143
|
-
(0, decorators_1.apiVersions)([1])
|
|
1144
|
-
], Collection.prototype, "createIndexes", null);
|
|
1145
|
-
__decorate([
|
|
1146
|
-
decorators_1.returnsPromise,
|
|
1147
|
-
(0, decorators_1.apiVersions)([1])
|
|
1148
|
-
], Collection.prototype, "createIndex", null);
|
|
1149
|
-
__decorate([
|
|
1150
|
-
decorators_1.returnsPromise,
|
|
1151
|
-
(0, decorators_1.apiVersions)([1])
|
|
1152
|
-
], Collection.prototype, "ensureIndex", null);
|
|
1153
|
-
__decorate([
|
|
1154
|
-
decorators_1.returnsPromise,
|
|
1155
|
-
(0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
|
|
1156
|
-
(0, decorators_1.apiVersions)([1])
|
|
1157
|
-
], Collection.prototype, "getIndexes", null);
|
|
1158
|
-
__decorate([
|
|
1159
|
-
decorators_1.returnsPromise,
|
|
1160
|
-
(0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
|
|
1161
|
-
(0, decorators_1.apiVersions)([1])
|
|
1162
|
-
], Collection.prototype, "getIndexSpecs", null);
|
|
1163
|
-
__decorate([
|
|
1164
|
-
decorators_1.returnsPromise,
|
|
1165
|
-
(0, decorators_1.apiVersions)([1])
|
|
1166
|
-
], Collection.prototype, "getIndices", null);
|
|
1167
|
-
__decorate([
|
|
1168
|
-
decorators_1.returnsPromise,
|
|
1169
|
-
(0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
|
|
1170
|
-
(0, decorators_1.apiVersions)([1])
|
|
1171
|
-
], Collection.prototype, "getIndexKeys", null);
|
|
1172
|
-
__decorate([
|
|
1173
|
-
decorators_1.returnsPromise,
|
|
1174
|
-
(0, decorators_1.apiVersions)([1])
|
|
1175
|
-
], Collection.prototype, "dropIndexes", null);
|
|
1176
|
-
__decorate([
|
|
1177
|
-
decorators_1.returnsPromise,
|
|
1178
|
-
(0, decorators_1.apiVersions)([1])
|
|
1179
|
-
], Collection.prototype, "dropIndex", null);
|
|
1180
|
-
__decorate([
|
|
1181
|
-
decorators_1.returnsPromise,
|
|
1182
|
-
(0, decorators_1.apiVersions)([])
|
|
1183
|
-
], Collection.prototype, "totalIndexSize", null);
|
|
1184
|
-
__decorate([
|
|
1185
|
-
decorators_1.returnsPromise,
|
|
1186
|
-
decorators_1.deprecated,
|
|
1187
|
-
(0, decorators_1.topologies)([enums_1.Topologies.Standalone]),
|
|
1188
|
-
(0, decorators_1.apiVersions)([])
|
|
1189
|
-
], Collection.prototype, "reIndex", null);
|
|
1190
|
-
__decorate([
|
|
1191
|
-
(0, decorators_1.returnType)('Database')
|
|
1192
|
-
], Collection.prototype, "getDB", null);
|
|
1193
|
-
__decorate([
|
|
1194
|
-
(0, decorators_1.returnType)('Mongo')
|
|
1195
|
-
], Collection.prototype, "getMongo", null);
|
|
1196
|
-
__decorate([
|
|
1197
|
-
decorators_1.returnsPromise,
|
|
1198
|
-
(0, decorators_1.apiVersions)([])
|
|
1199
|
-
], Collection.prototype, "dataSize", null);
|
|
1200
|
-
__decorate([
|
|
1201
|
-
decorators_1.returnsPromise,
|
|
1202
|
-
(0, decorators_1.apiVersions)([])
|
|
1203
|
-
], Collection.prototype, "storageSize", null);
|
|
1204
|
-
__decorate([
|
|
1205
|
-
decorators_1.returnsPromise,
|
|
1206
|
-
(0, decorators_1.apiVersions)([])
|
|
1207
|
-
], Collection.prototype, "totalSize", null);
|
|
1208
|
-
__decorate([
|
|
1209
|
-
decorators_1.returnsPromise,
|
|
1210
|
-
(0, decorators_1.apiVersions)([1])
|
|
1211
|
-
], Collection.prototype, "drop", null);
|
|
1212
|
-
__decorate([
|
|
1213
|
-
decorators_1.returnsPromise,
|
|
1214
|
-
(0, decorators_1.apiVersions)([1])
|
|
1215
|
-
], Collection.prototype, "exists", null);
|
|
1216
|
-
__decorate([
|
|
1217
|
-
decorators_1.returnsPromise,
|
|
1218
|
-
(0, decorators_1.apiVersions)([1])
|
|
1219
|
-
], Collection.prototype, "runCommand", null);
|
|
1220
|
-
__decorate([
|
|
1221
|
-
(0, decorators_1.returnType)('Explainable'),
|
|
1222
|
-
(0, decorators_1.apiVersions)([1])
|
|
1223
|
-
], Collection.prototype, "explain", null);
|
|
1224
|
-
__decorate([
|
|
1225
|
-
decorators_1.returnsPromise,
|
|
1226
|
-
(0, decorators_1.apiVersions)([])
|
|
1227
|
-
], Collection.prototype, "stats", null);
|
|
1228
|
-
__decorate([
|
|
1229
|
-
decorators_1.returnsPromise,
|
|
1230
|
-
(0, decorators_1.apiVersions)([])
|
|
1231
|
-
], Collection.prototype, "latencyStats", null);
|
|
1232
|
-
__decorate([
|
|
1233
|
-
decorators_1.returnsPromise,
|
|
1234
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
1235
|
-
(0, decorators_1.apiVersions)([1])
|
|
1236
|
-
], Collection.prototype, "initializeOrderedBulkOp", null);
|
|
1237
|
-
__decorate([
|
|
1238
|
-
decorators_1.returnsPromise,
|
|
1239
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
1240
|
-
(0, decorators_1.apiVersions)([1])
|
|
1241
|
-
], Collection.prototype, "initializeUnorderedBulkOp", null);
|
|
1242
|
-
__decorate([
|
|
1243
|
-
(0, decorators_1.returnType)('PlanCache'),
|
|
1244
|
-
(0, decorators_1.apiVersions)([])
|
|
1245
|
-
], Collection.prototype, "getPlanCache", null);
|
|
1246
|
-
__decorate([
|
|
1247
|
-
decorators_1.returnsPromise,
|
|
1248
|
-
decorators_1.deprecated,
|
|
1249
|
-
(0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '4.9.0']),
|
|
1250
|
-
(0, decorators_1.apiVersions)([])
|
|
1251
|
-
], Collection.prototype, "mapReduce", null);
|
|
1252
|
-
__decorate([
|
|
1253
|
-
decorators_1.returnsPromise,
|
|
1254
|
-
(0, decorators_1.apiVersions)([])
|
|
1255
|
-
], Collection.prototype, "validate", null);
|
|
1256
|
-
__decorate([
|
|
1257
|
-
decorators_1.returnsPromise,
|
|
1258
|
-
(0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
|
|
1259
|
-
(0, decorators_1.apiVersions)([])
|
|
1260
|
-
], Collection.prototype, "getShardVersion", null);
|
|
1261
|
-
__decorate([
|
|
1262
|
-
decorators_1.returnsPromise,
|
|
1263
|
-
(0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
|
|
1264
|
-
(0, decorators_1.apiVersions)([])
|
|
1265
|
-
], Collection.prototype, "getShardDistribution", null);
|
|
1266
|
-
__decorate([
|
|
1267
|
-
(0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]),
|
|
1268
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
|
|
1269
|
-
(0, decorators_1.apiVersions)([1]),
|
|
1270
|
-
decorators_1.returnsPromise
|
|
1271
|
-
], Collection.prototype, "watch", null);
|
|
1272
|
-
__decorate([
|
|
1273
|
-
(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]),
|
|
1274
|
-
decorators_1.returnsPromise,
|
|
1275
|
-
(0, decorators_1.apiVersions)([1])
|
|
1276
|
-
], Collection.prototype, "hideIndex", null);
|
|
1277
|
-
__decorate([
|
|
1278
|
-
(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]),
|
|
1279
|
-
decorators_1.returnsPromise,
|
|
1280
|
-
(0, decorators_1.apiVersions)([1])
|
|
1281
|
-
], Collection.prototype, "unhideIndex", null);
|
|
1282
|
-
__decorate([
|
|
1283
|
-
(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]),
|
|
1284
|
-
decorators_1.returnsPromise,
|
|
1285
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
|
|
1286
|
-
(0, decorators_1.apiVersions)([])
|
|
1287
|
-
], Collection.prototype, "analyzeShardKey", null);
|
|
1288
|
-
__decorate([
|
|
1289
|
-
(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]),
|
|
1290
|
-
decorators_1.returnsPromise,
|
|
1291
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
|
|
1292
|
-
(0, decorators_1.apiVersions)([])
|
|
1293
|
-
], Collection.prototype, "configureQueryAnalyzer", null);
|
|
1294
|
-
__decorate([
|
|
1295
|
-
(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]),
|
|
1296
|
-
(0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
|
|
1297
|
-
decorators_1.returnsPromise
|
|
1298
|
-
], Collection.prototype, "checkMetadataConsistency", null);
|
|
1299
|
-
__decorate([
|
|
1300
|
-
(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]),
|
|
1301
|
-
decorators_1.returnsPromise,
|
|
1302
|
-
(0, decorators_1.apiVersions)([])
|
|
1303
|
-
], Collection.prototype, "getSearchIndexes", null);
|
|
1304
|
-
__decorate([
|
|
1305
|
-
(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]),
|
|
1306
|
-
decorators_1.returnsPromise,
|
|
1307
|
-
(0, decorators_1.apiVersions)([])
|
|
1308
|
-
], Collection.prototype, "createSearchIndex", null);
|
|
1309
|
-
__decorate([
|
|
1310
|
-
(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]),
|
|
1311
|
-
decorators_1.returnsPromise,
|
|
1312
|
-
(0, decorators_1.apiVersions)([])
|
|
1313
|
-
], Collection.prototype, "createSearchIndexes", null);
|
|
1314
|
-
__decorate([
|
|
1315
|
-
(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]),
|
|
1316
|
-
decorators_1.returnsPromise,
|
|
1317
|
-
(0, decorators_1.apiVersions)([])
|
|
1318
|
-
], Collection.prototype, "dropSearchIndex", null);
|
|
1319
|
-
__decorate([
|
|
1320
|
-
(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]),
|
|
1321
|
-
decorators_1.returnsPromise,
|
|
1322
|
-
(0, decorators_1.apiVersions)([])
|
|
1323
|
-
], Collection.prototype, "updateSearchIndex", null);
|
|
1324
|
-
Collection = __decorate([
|
|
1325
|
-
decorators_1.shellApiClassDefault,
|
|
1326
|
-
decorators_1.addSourceToResults
|
|
1327
|
-
], Collection);
|
|
1128
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
1129
|
+
_aggregate_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('AggregationCursor'), (0, decorators_1.apiVersions)([1])];
|
|
1130
|
+
_bulkWrite_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1131
|
+
_count_decorators = [decorators_1.returnsPromise, decorators_1.deprecated, (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '4.0.0']), (0, decorators_1.apiVersions)([])];
|
|
1132
|
+
_countDocuments_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['4.0.3', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1133
|
+
_deleteMany_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1134
|
+
_deleteOne_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1135
|
+
_distinct_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1136
|
+
_estimatedDocumentCount_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['4.0.3', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1137
|
+
_find_decorators = [(0, decorators_1.returnType)('Cursor'), (0, decorators_1.apiVersions)([1]), decorators_1.returnsPromise];
|
|
1138
|
+
_findAndModify_decorators = [decorators_1.returnsPromise, decorators_1.deprecated, (0, decorators_1.apiVersions)([1])];
|
|
1139
|
+
_findOne_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('Document'), (0, decorators_1.apiVersions)([1])];
|
|
1140
|
+
_renameCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1141
|
+
_findOneAndDelete_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('Document'), (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1142
|
+
_findOneAndReplace_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('Document'), (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1143
|
+
_findOneAndUpdate_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('Document'), (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1144
|
+
_insert_decorators = [decorators_1.returnsPromise, decorators_1.deprecated, (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '3.6.0']), (0, decorators_1.apiVersions)([1])];
|
|
1145
|
+
_insertMany_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1146
|
+
_insertOne_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1147
|
+
_isCapped_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1148
|
+
_remove_decorators = [decorators_1.returnsPromise, decorators_1.deprecated, (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '3.2.0']), (0, decorators_1.apiVersions)([1])];
|
|
1149
|
+
_replaceOne_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1150
|
+
_update_decorators = [decorators_1.returnsPromise, decorators_1.deprecated, (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '3.2.0']), (0, decorators_1.apiVersions)([1])];
|
|
1151
|
+
_updateMany_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1152
|
+
_updateOne_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1153
|
+
_compactStructuredEncryptionData_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1154
|
+
_convertToCapped_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1155
|
+
_createIndexes_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1156
|
+
_createIndex_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1157
|
+
_ensureIndex_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1158
|
+
_getIndexes_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1159
|
+
_getIndexSpecs_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1160
|
+
_getIndices_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1161
|
+
_getIndexKeys_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1162
|
+
_dropIndexes_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1163
|
+
_dropIndex_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1164
|
+
_totalIndexSize_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1165
|
+
_reIndex_decorators = [decorators_1.returnsPromise, decorators_1.deprecated, (0, decorators_1.topologies)([enums_1.Topologies.Standalone]), (0, decorators_1.apiVersions)([])];
|
|
1166
|
+
_getDB_decorators = [(0, decorators_1.returnType)('Database')];
|
|
1167
|
+
_getMongo_decorators = [(0, decorators_1.returnType)('Mongo')];
|
|
1168
|
+
_dataSize_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1169
|
+
_storageSize_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1170
|
+
_totalSize_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1171
|
+
_drop_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1172
|
+
_exists_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1173
|
+
_runCommand_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1174
|
+
_explain_decorators = [(0, decorators_1.returnType)('Explainable'), (0, decorators_1.apiVersions)([1])];
|
|
1175
|
+
_stats_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1176
|
+
_latencyStats_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1177
|
+
_initializeOrderedBulkOp_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('Bulk'), (0, decorators_1.apiVersions)([1])];
|
|
1178
|
+
_initializeUnorderedBulkOp_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('Bulk'), (0, decorators_1.apiVersions)([1])];
|
|
1179
|
+
_getPlanCache_decorators = [(0, decorators_1.returnType)('PlanCache'), (0, decorators_1.apiVersions)([])];
|
|
1180
|
+
_mapReduce_decorators = [decorators_1.returnsPromise, decorators_1.deprecated, (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '4.9.0']), (0, decorators_1.apiVersions)([])];
|
|
1181
|
+
_validate_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1182
|
+
_getShardVersion_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([])];
|
|
1183
|
+
_getShardDistribution_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([])];
|
|
1184
|
+
_watch_decorators = [(0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]), (0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([1]), decorators_1.returnsPromise];
|
|
1185
|
+
_hideIndex_decorators = [(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1186
|
+
_unhideIndex_decorators = [(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1187
|
+
_analyzeShardKey_decorators = [(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([])];
|
|
1188
|
+
_configureQueryAnalyzer_decorators = [(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([])];
|
|
1189
|
+
_checkMetadataConsistency_decorators = [(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]), (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), decorators_1.returnsPromise];
|
|
1190
|
+
_getSearchIndexes_decorators = [(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1191
|
+
_createSearchIndex_decorators = [(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1192
|
+
_createSearchIndexes_decorators = [(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1193
|
+
_dropSearchIndex_decorators = [(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1194
|
+
_updateSearchIndex_decorators = [(0, decorators_1.serverVersions)(['6.0.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1195
|
+
__esDecorate(_classThis, null, _aggregate_decorators, { kind: "method", name: "aggregate", static: false, private: false, access: { has: obj => "aggregate" in obj, get: obj => obj.aggregate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1196
|
+
__esDecorate(_classThis, null, _bulkWrite_decorators, { kind: "method", name: "bulkWrite", static: false, private: false, access: { has: obj => "bulkWrite" in obj, get: obj => obj.bulkWrite }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1197
|
+
__esDecorate(_classThis, null, _count_decorators, { kind: "method", name: "count", static: false, private: false, access: { has: obj => "count" in obj, get: obj => obj.count }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1198
|
+
__esDecorate(_classThis, null, _countDocuments_decorators, { kind: "method", name: "countDocuments", static: false, private: false, access: { has: obj => "countDocuments" in obj, get: obj => obj.countDocuments }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1199
|
+
__esDecorate(_classThis, null, _deleteMany_decorators, { kind: "method", name: "deleteMany", static: false, private: false, access: { has: obj => "deleteMany" in obj, get: obj => obj.deleteMany }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1200
|
+
__esDecorate(_classThis, null, _deleteOne_decorators, { kind: "method", name: "deleteOne", static: false, private: false, access: { has: obj => "deleteOne" in obj, get: obj => obj.deleteOne }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1201
|
+
__esDecorate(_classThis, null, _distinct_decorators, { kind: "method", name: "distinct", static: false, private: false, access: { has: obj => "distinct" in obj, get: obj => obj.distinct }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1202
|
+
__esDecorate(_classThis, null, _estimatedDocumentCount_decorators, { kind: "method", name: "estimatedDocumentCount", static: false, private: false, access: { has: obj => "estimatedDocumentCount" in obj, get: obj => obj.estimatedDocumentCount }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1203
|
+
__esDecorate(_classThis, null, _find_decorators, { kind: "method", name: "find", static: false, private: false, access: { has: obj => "find" in obj, get: obj => obj.find }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1204
|
+
__esDecorate(_classThis, null, _findAndModify_decorators, { kind: "method", name: "findAndModify", static: false, private: false, access: { has: obj => "findAndModify" in obj, get: obj => obj.findAndModify }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1205
|
+
__esDecorate(_classThis, null, _findOne_decorators, { kind: "method", name: "findOne", static: false, private: false, access: { has: obj => "findOne" in obj, get: obj => obj.findOne }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1206
|
+
__esDecorate(_classThis, null, _renameCollection_decorators, { kind: "method", name: "renameCollection", static: false, private: false, access: { has: obj => "renameCollection" in obj, get: obj => obj.renameCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1207
|
+
__esDecorate(_classThis, null, _findOneAndDelete_decorators, { kind: "method", name: "findOneAndDelete", static: false, private: false, access: { has: obj => "findOneAndDelete" in obj, get: obj => obj.findOneAndDelete }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1208
|
+
__esDecorate(_classThis, null, _findOneAndReplace_decorators, { kind: "method", name: "findOneAndReplace", static: false, private: false, access: { has: obj => "findOneAndReplace" in obj, get: obj => obj.findOneAndReplace }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1209
|
+
__esDecorate(_classThis, null, _findOneAndUpdate_decorators, { kind: "method", name: "findOneAndUpdate", static: false, private: false, access: { has: obj => "findOneAndUpdate" in obj, get: obj => obj.findOneAndUpdate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1210
|
+
__esDecorate(_classThis, null, _insert_decorators, { kind: "method", name: "insert", static: false, private: false, access: { has: obj => "insert" in obj, get: obj => obj.insert }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1211
|
+
__esDecorate(_classThis, null, _insertMany_decorators, { kind: "method", name: "insertMany", static: false, private: false, access: { has: obj => "insertMany" in obj, get: obj => obj.insertMany }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1212
|
+
__esDecorate(_classThis, null, _insertOne_decorators, { kind: "method", name: "insertOne", static: false, private: false, access: { has: obj => "insertOne" in obj, get: obj => obj.insertOne }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1213
|
+
__esDecorate(_classThis, null, _isCapped_decorators, { kind: "method", name: "isCapped", static: false, private: false, access: { has: obj => "isCapped" in obj, get: obj => obj.isCapped }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1214
|
+
__esDecorate(_classThis, null, _remove_decorators, { kind: "method", name: "remove", static: false, private: false, access: { has: obj => "remove" in obj, get: obj => obj.remove }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1215
|
+
__esDecorate(_classThis, null, _replaceOne_decorators, { kind: "method", name: "replaceOne", static: false, private: false, access: { has: obj => "replaceOne" in obj, get: obj => obj.replaceOne }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1216
|
+
__esDecorate(_classThis, null, _update_decorators, { kind: "method", name: "update", static: false, private: false, access: { has: obj => "update" in obj, get: obj => obj.update }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1217
|
+
__esDecorate(_classThis, null, _updateMany_decorators, { kind: "method", name: "updateMany", static: false, private: false, access: { has: obj => "updateMany" in obj, get: obj => obj.updateMany }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1218
|
+
__esDecorate(_classThis, null, _updateOne_decorators, { kind: "method", name: "updateOne", static: false, private: false, access: { has: obj => "updateOne" in obj, get: obj => obj.updateOne }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1219
|
+
__esDecorate(_classThis, null, _compactStructuredEncryptionData_decorators, { kind: "method", name: "compactStructuredEncryptionData", static: false, private: false, access: { has: obj => "compactStructuredEncryptionData" in obj, get: obj => obj.compactStructuredEncryptionData }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1220
|
+
__esDecorate(_classThis, null, _convertToCapped_decorators, { kind: "method", name: "convertToCapped", static: false, private: false, access: { has: obj => "convertToCapped" in obj, get: obj => obj.convertToCapped }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1221
|
+
__esDecorate(_classThis, null, _createIndexes_decorators, { kind: "method", name: "createIndexes", static: false, private: false, access: { has: obj => "createIndexes" in obj, get: obj => obj.createIndexes }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1222
|
+
__esDecorate(_classThis, null, _createIndex_decorators, { kind: "method", name: "createIndex", static: false, private: false, access: { has: obj => "createIndex" in obj, get: obj => obj.createIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1223
|
+
__esDecorate(_classThis, null, _ensureIndex_decorators, { kind: "method", name: "ensureIndex", static: false, private: false, access: { has: obj => "ensureIndex" in obj, get: obj => obj.ensureIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1224
|
+
__esDecorate(_classThis, null, _getIndexes_decorators, { kind: "method", name: "getIndexes", static: false, private: false, access: { has: obj => "getIndexes" in obj, get: obj => obj.getIndexes }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1225
|
+
__esDecorate(_classThis, null, _getIndexSpecs_decorators, { kind: "method", name: "getIndexSpecs", static: false, private: false, access: { has: obj => "getIndexSpecs" in obj, get: obj => obj.getIndexSpecs }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1226
|
+
__esDecorate(_classThis, null, _getIndices_decorators, { kind: "method", name: "getIndices", static: false, private: false, access: { has: obj => "getIndices" in obj, get: obj => obj.getIndices }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1227
|
+
__esDecorate(_classThis, null, _getIndexKeys_decorators, { kind: "method", name: "getIndexKeys", static: false, private: false, access: { has: obj => "getIndexKeys" in obj, get: obj => obj.getIndexKeys }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1228
|
+
__esDecorate(_classThis, null, _dropIndexes_decorators, { kind: "method", name: "dropIndexes", static: false, private: false, access: { has: obj => "dropIndexes" in obj, get: obj => obj.dropIndexes }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1229
|
+
__esDecorate(_classThis, null, _dropIndex_decorators, { kind: "method", name: "dropIndex", static: false, private: false, access: { has: obj => "dropIndex" in obj, get: obj => obj.dropIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1230
|
+
__esDecorate(_classThis, null, _totalIndexSize_decorators, { kind: "method", name: "totalIndexSize", static: false, private: false, access: { has: obj => "totalIndexSize" in obj, get: obj => obj.totalIndexSize }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1231
|
+
__esDecorate(_classThis, null, _reIndex_decorators, { kind: "method", name: "reIndex", static: false, private: false, access: { has: obj => "reIndex" in obj, get: obj => obj.reIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1232
|
+
__esDecorate(_classThis, null, _getDB_decorators, { kind: "method", name: "getDB", static: false, private: false, access: { has: obj => "getDB" in obj, get: obj => obj.getDB }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1233
|
+
__esDecorate(_classThis, null, _getMongo_decorators, { kind: "method", name: "getMongo", static: false, private: false, access: { has: obj => "getMongo" in obj, get: obj => obj.getMongo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1234
|
+
__esDecorate(_classThis, null, _dataSize_decorators, { kind: "method", name: "dataSize", static: false, private: false, access: { has: obj => "dataSize" in obj, get: obj => obj.dataSize }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1235
|
+
__esDecorate(_classThis, null, _storageSize_decorators, { kind: "method", name: "storageSize", static: false, private: false, access: { has: obj => "storageSize" in obj, get: obj => obj.storageSize }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1236
|
+
__esDecorate(_classThis, null, _totalSize_decorators, { kind: "method", name: "totalSize", static: false, private: false, access: { has: obj => "totalSize" in obj, get: obj => obj.totalSize }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1237
|
+
__esDecorate(_classThis, null, _drop_decorators, { kind: "method", name: "drop", static: false, private: false, access: { has: obj => "drop" in obj, get: obj => obj.drop }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1238
|
+
__esDecorate(_classThis, null, _exists_decorators, { kind: "method", name: "exists", static: false, private: false, access: { has: obj => "exists" in obj, get: obj => obj.exists }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1239
|
+
__esDecorate(_classThis, null, _runCommand_decorators, { kind: "method", name: "runCommand", static: false, private: false, access: { has: obj => "runCommand" in obj, get: obj => obj.runCommand }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1240
|
+
__esDecorate(_classThis, null, _explain_decorators, { kind: "method", name: "explain", static: false, private: false, access: { has: obj => "explain" in obj, get: obj => obj.explain }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1241
|
+
__esDecorate(_classThis, null, _stats_decorators, { kind: "method", name: "stats", static: false, private: false, access: { has: obj => "stats" in obj, get: obj => obj.stats }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1242
|
+
__esDecorate(_classThis, null, _latencyStats_decorators, { kind: "method", name: "latencyStats", static: false, private: false, access: { has: obj => "latencyStats" in obj, get: obj => obj.latencyStats }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1243
|
+
__esDecorate(_classThis, null, _initializeOrderedBulkOp_decorators, { kind: "method", name: "initializeOrderedBulkOp", static: false, private: false, access: { has: obj => "initializeOrderedBulkOp" in obj, get: obj => obj.initializeOrderedBulkOp }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1244
|
+
__esDecorate(_classThis, null, _initializeUnorderedBulkOp_decorators, { kind: "method", name: "initializeUnorderedBulkOp", static: false, private: false, access: { has: obj => "initializeUnorderedBulkOp" in obj, get: obj => obj.initializeUnorderedBulkOp }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1245
|
+
__esDecorate(_classThis, null, _getPlanCache_decorators, { kind: "method", name: "getPlanCache", static: false, private: false, access: { has: obj => "getPlanCache" in obj, get: obj => obj.getPlanCache }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1246
|
+
__esDecorate(_classThis, null, _mapReduce_decorators, { kind: "method", name: "mapReduce", static: false, private: false, access: { has: obj => "mapReduce" in obj, get: obj => obj.mapReduce }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1247
|
+
__esDecorate(_classThis, null, _validate_decorators, { kind: "method", name: "validate", static: false, private: false, access: { has: obj => "validate" in obj, get: obj => obj.validate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1248
|
+
__esDecorate(_classThis, null, _getShardVersion_decorators, { kind: "method", name: "getShardVersion", static: false, private: false, access: { has: obj => "getShardVersion" in obj, get: obj => obj.getShardVersion }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1249
|
+
__esDecorate(_classThis, null, _getShardDistribution_decorators, { kind: "method", name: "getShardDistribution", static: false, private: false, access: { has: obj => "getShardDistribution" in obj, get: obj => obj.getShardDistribution }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1250
|
+
__esDecorate(_classThis, null, _watch_decorators, { kind: "method", name: "watch", static: false, private: false, access: { has: obj => "watch" in obj, get: obj => obj.watch }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1251
|
+
__esDecorate(_classThis, null, _hideIndex_decorators, { kind: "method", name: "hideIndex", static: false, private: false, access: { has: obj => "hideIndex" in obj, get: obj => obj.hideIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1252
|
+
__esDecorate(_classThis, null, _unhideIndex_decorators, { kind: "method", name: "unhideIndex", static: false, private: false, access: { has: obj => "unhideIndex" in obj, get: obj => obj.unhideIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1253
|
+
__esDecorate(_classThis, null, _analyzeShardKey_decorators, { kind: "method", name: "analyzeShardKey", static: false, private: false, access: { has: obj => "analyzeShardKey" in obj, get: obj => obj.analyzeShardKey }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1254
|
+
__esDecorate(_classThis, null, _configureQueryAnalyzer_decorators, { kind: "method", name: "configureQueryAnalyzer", static: false, private: false, access: { has: obj => "configureQueryAnalyzer" in obj, get: obj => obj.configureQueryAnalyzer }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1255
|
+
__esDecorate(_classThis, null, _checkMetadataConsistency_decorators, { kind: "method", name: "checkMetadataConsistency", static: false, private: false, access: { has: obj => "checkMetadataConsistency" in obj, get: obj => obj.checkMetadataConsistency }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1256
|
+
__esDecorate(_classThis, null, _getSearchIndexes_decorators, { kind: "method", name: "getSearchIndexes", static: false, private: false, access: { has: obj => "getSearchIndexes" in obj, get: obj => obj.getSearchIndexes }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1257
|
+
__esDecorate(_classThis, null, _createSearchIndex_decorators, { kind: "method", name: "createSearchIndex", static: false, private: false, access: { has: obj => "createSearchIndex" in obj, get: obj => obj.createSearchIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1258
|
+
__esDecorate(_classThis, null, _createSearchIndexes_decorators, { kind: "method", name: "createSearchIndexes", static: false, private: false, access: { has: obj => "createSearchIndexes" in obj, get: obj => obj.createSearchIndexes }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1259
|
+
__esDecorate(_classThis, null, _dropSearchIndex_decorators, { kind: "method", name: "dropSearchIndex", static: false, private: false, access: { has: obj => "dropSearchIndex" in obj, get: obj => obj.dropSearchIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1260
|
+
__esDecorate(_classThis, null, _updateSearchIndex_decorators, { kind: "method", name: "updateSearchIndex", static: false, private: false, access: { has: obj => "updateSearchIndex" in obj, get: obj => obj.updateSearchIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1261
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1262
|
+
Collection = _classThis = _classDescriptor.value;
|
|
1263
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1264
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1265
|
+
})();
|
|
1266
|
+
return Collection = _classThis;
|
|
1267
|
+
})();
|
|
1328
1268
|
exports.default = Collection;
|
|
1329
1269
|
//# sourceMappingURL=collection.js.map
|