@qp-mongosh/shell-api 0.0.0-dev.5 → 0.0.0-dev.9
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/.eslintignore +2 -2
- package/.eslintrc.js +1 -1
- package/AUTHORS +15 -15
- package/LICENSE +200 -200
- package/bin/report-missing-help.ts +24 -24
- package/bin/report-supported-api.ts +14 -14
- package/lib/abstract-cursor.d.ts +33 -33
- package/lib/abstract-cursor.js +191 -191
- package/lib/aggregation-cursor.d.ts +6 -6
- package/lib/aggregation-cursor.js +19 -19
- package/lib/bulk.d.ts +43 -43
- package/lib/bulk.js +223 -223
- package/lib/change-stream-cursor.d.ts +28 -28
- package/lib/change-stream-cursor.js +111 -111
- package/lib/collection.d.ts +95 -95
- package/lib/collection.js +964 -964
- package/lib/cursor.d.ts +32 -32
- package/lib/cursor.js +215 -215
- package/lib/database.d.ts +116 -116
- package/lib/database.js +1223 -1223
- package/lib/dbquery.d.ts +8 -8
- package/lib/dbquery.js +28 -28
- package/lib/decorators.d.ts +73 -73
- package/lib/decorators.js +395 -395
- package/lib/enums.d.ts +28 -28
- package/lib/enums.js +33 -33
- package/lib/error-codes.d.ts +12 -12
- package/lib/error-codes.js +19 -19
- package/lib/explainable-cursor.d.ts +11 -11
- package/lib/explainable-cursor.js +31 -31
- package/lib/explainable.d.ts +32 -32
- package/lib/explainable.js +166 -166
- package/lib/field-level-encryption.d.ts +50 -50
- package/lib/field-level-encryption.js +176 -176
- package/lib/help.d.ts +22 -22
- package/lib/help.js +26 -26
- package/lib/helpers.d.ts +71 -71
- package/lib/helpers.js +588 -588
- package/lib/index.d.ts +16 -16
- package/lib/index.js +45 -45
- package/lib/interruptor.d.ts +19 -19
- package/lib/interruptor.js +62 -62
- package/lib/mongo-errors.d.ts +5 -5
- package/lib/mongo-errors.js +37 -37
- package/lib/mongo.d.ts +75 -75
- package/lib/mongo.js +476 -476
- package/lib/no-db.d.ts +5 -5
- package/lib/no-db.js +28 -28
- package/lib/plan-cache.d.ts +16 -16
- package/lib/plan-cache.js +70 -70
- package/lib/replica-set.d.ts +45 -45
- package/lib/replica-set.js +314 -314
- package/lib/result.d.ts +61 -61
- package/lib/result.js +104 -104
- package/lib/session.d.ts +25 -25
- package/lib/session.js +88 -88
- package/lib/shard.d.ts +42 -42
- package/lib/shard.js +414 -414
- package/lib/shell-api.d.ts +52 -52
- package/lib/shell-api.js +298 -298
- package/lib/shell-bson.d.ts +40 -40
- package/lib/shell-bson.js +159 -159
- package/lib/shell-instance-state.d.ts +77 -77
- package/lib/shell-instance-state.js +392 -392
- package/package.json +47 -47
- package/tsconfig.lint.json +8 -8
package/lib/bulk.js
CHANGED
|
@@ -1,224 +1,224 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.BulkFindOp = void 0;
|
|
10
|
-
const decorators_1 = require("./decorators");
|
|
11
|
-
const errors_1 = require("@qp-mongosh/errors");
|
|
12
|
-
const enums_1 = require("./enums");
|
|
13
|
-
const helpers_1 = require("./helpers");
|
|
14
|
-
const result_1 = require("./result");
|
|
15
|
-
let BulkFindOp = class BulkFindOp extends decorators_1.ShellApiWithMongoClass {
|
|
16
|
-
constructor(innerFind, parentBulk) {
|
|
17
|
-
super();
|
|
18
|
-
this._serviceProviderBulkFindOp = innerFind;
|
|
19
|
-
this._parentBulk = parentBulk;
|
|
20
|
-
}
|
|
21
|
-
get _mongo() {
|
|
22
|
-
return this._parentBulk._mongo;
|
|
23
|
-
}
|
|
24
|
-
[enums_1.asPrintable]() {
|
|
25
|
-
return 'BulkFindOp';
|
|
26
|
-
}
|
|
27
|
-
collation(spec) {
|
|
28
|
-
this._serviceProviderBulkFindOp.collation(spec);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
arrayFilters(filters) {
|
|
32
|
-
this._serviceProviderBulkFindOp.arrayFilters(filters);
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
hint(hintDoc) {
|
|
36
|
-
(0, helpers_1.assertArgsDefinedType)([hintDoc], [true], 'BulkFindOp.hint');
|
|
37
|
-
this._hint = hintDoc;
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
delete() {
|
|
41
|
-
this._parentBulk._batchCounts.nRemoveOps++;
|
|
42
|
-
this._serviceProviderBulkFindOp.delete();
|
|
43
|
-
return this._parentBulk;
|
|
44
|
-
}
|
|
45
|
-
deleteOne() {
|
|
46
|
-
this._parentBulk._batchCounts.nRemoveOps++;
|
|
47
|
-
this._serviceProviderBulkFindOp.deleteOne();
|
|
48
|
-
return this._parentBulk;
|
|
49
|
-
}
|
|
50
|
-
remove() {
|
|
51
|
-
return this.delete();
|
|
52
|
-
}
|
|
53
|
-
removeOne() {
|
|
54
|
-
return this.deleteOne();
|
|
55
|
-
}
|
|
56
|
-
replaceOne(replacement) {
|
|
57
|
-
this._parentBulk._batchCounts.nUpdateOps++;
|
|
58
|
-
(0, helpers_1.assertArgsDefinedType)([replacement], [true], 'BulkFindOp.replacement');
|
|
59
|
-
const op = { ...replacement };
|
|
60
|
-
if (this._hint) {
|
|
61
|
-
op.hint = this._hint;
|
|
62
|
-
}
|
|
63
|
-
this._serviceProviderBulkFindOp.replaceOne(op);
|
|
64
|
-
return this._parentBulk;
|
|
65
|
-
}
|
|
66
|
-
updateOne(update) {
|
|
67
|
-
this._parentBulk._batchCounts.nUpdateOps++;
|
|
68
|
-
(0, helpers_1.assertArgsDefinedType)([update], [true], 'BulkFindOp.update');
|
|
69
|
-
const op = { ...update };
|
|
70
|
-
if (this._hint) {
|
|
71
|
-
op.hint = this._hint;
|
|
72
|
-
}
|
|
73
|
-
if (this._arrayFilters) {
|
|
74
|
-
op.arrayFilters = this._arrayFilters;
|
|
75
|
-
}
|
|
76
|
-
this._serviceProviderBulkFindOp.updateOne(op);
|
|
77
|
-
return this._parentBulk;
|
|
78
|
-
}
|
|
79
|
-
update(update) {
|
|
80
|
-
this._parentBulk._batchCounts.nUpdateOps++;
|
|
81
|
-
(0, helpers_1.assertArgsDefinedType)([update], [true], 'BulkFindOp.update');
|
|
82
|
-
const op = { ...update };
|
|
83
|
-
if (this._hint) {
|
|
84
|
-
op.hint = this._hint;
|
|
85
|
-
}
|
|
86
|
-
if (this._arrayFilters) {
|
|
87
|
-
op.arrayFilters = this._arrayFilters;
|
|
88
|
-
}
|
|
89
|
-
this._serviceProviderBulkFindOp.update(op);
|
|
90
|
-
return this._parentBulk;
|
|
91
|
-
}
|
|
92
|
-
upsert() {
|
|
93
|
-
this._serviceProviderBulkFindOp.upsert();
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
__decorate([
|
|
98
|
-
(0, decorators_1.returnType)('BulkFindOp'),
|
|
99
|
-
(0, decorators_1.apiVersions)([1])
|
|
100
|
-
], BulkFindOp.prototype, "collation", null);
|
|
101
|
-
__decorate([
|
|
102
|
-
(0, decorators_1.returnType)('BulkFindOp'),
|
|
103
|
-
(0, decorators_1.apiVersions)([1])
|
|
104
|
-
], BulkFindOp.prototype, "arrayFilters", null);
|
|
105
|
-
__decorate([
|
|
106
|
-
(0, decorators_1.returnType)('BulkFindOp'),
|
|
107
|
-
(0, decorators_1.apiVersions)([1])
|
|
108
|
-
], BulkFindOp.prototype, "hint", null);
|
|
109
|
-
__decorate([
|
|
110
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
111
|
-
(0, decorators_1.apiVersions)([1])
|
|
112
|
-
], BulkFindOp.prototype, "delete", null);
|
|
113
|
-
__decorate([
|
|
114
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
115
|
-
(0, decorators_1.apiVersions)([1])
|
|
116
|
-
], BulkFindOp.prototype, "deleteOne", null);
|
|
117
|
-
__decorate([
|
|
118
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
119
|
-
(0, decorators_1.apiVersions)([1]),
|
|
120
|
-
decorators_1.deprecated
|
|
121
|
-
], BulkFindOp.prototype, "remove", null);
|
|
122
|
-
__decorate([
|
|
123
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
124
|
-
(0, decorators_1.apiVersions)([1]),
|
|
125
|
-
decorators_1.deprecated
|
|
126
|
-
], BulkFindOp.prototype, "removeOne", null);
|
|
127
|
-
__decorate([
|
|
128
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
129
|
-
(0, decorators_1.apiVersions)([1])
|
|
130
|
-
], BulkFindOp.prototype, "replaceOne", null);
|
|
131
|
-
__decorate([
|
|
132
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
133
|
-
(0, decorators_1.apiVersions)([1])
|
|
134
|
-
], BulkFindOp.prototype, "updateOne", null);
|
|
135
|
-
__decorate([
|
|
136
|
-
(0, decorators_1.returnType)('Bulk')
|
|
137
|
-
], BulkFindOp.prototype, "update", null);
|
|
138
|
-
__decorate([
|
|
139
|
-
(0, decorators_1.returnType)('Bulk')
|
|
140
|
-
], BulkFindOp.prototype, "upsert", null);
|
|
141
|
-
BulkFindOp = __decorate([
|
|
142
|
-
decorators_1.shellApiClassDefault
|
|
143
|
-
], BulkFindOp);
|
|
144
|
-
exports.BulkFindOp = BulkFindOp;
|
|
145
|
-
let Bulk = class Bulk extends decorators_1.ShellApiWithMongoClass {
|
|
146
|
-
constructor(collection, innerBulk, ordered = false) {
|
|
147
|
-
super();
|
|
148
|
-
this._collection = collection;
|
|
149
|
-
this._mongo = collection._mongo;
|
|
150
|
-
this._serviceProviderBulkOp = innerBulk;
|
|
151
|
-
this._batchCounts = {
|
|
152
|
-
nInsertOps: 0,
|
|
153
|
-
nUpdateOps: 0,
|
|
154
|
-
nRemoveOps: 0
|
|
155
|
-
};
|
|
156
|
-
this._executed = false;
|
|
157
|
-
this._ordered = ordered;
|
|
158
|
-
}
|
|
159
|
-
[enums_1.asPrintable]() {
|
|
160
|
-
return this.toJSON();
|
|
161
|
-
}
|
|
162
|
-
_emitBulkApiCall(methodName, methodArguments = {}) {
|
|
163
|
-
this._mongo._instanceState.emitApiCallWithArgs({
|
|
164
|
-
method: methodName,
|
|
165
|
-
class: 'Bulk',
|
|
166
|
-
db: this._collection._database._name,
|
|
167
|
-
coll: this._collection._name,
|
|
168
|
-
arguments: methodArguments
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
async execute(writeConcern) {
|
|
172
|
-
const { result } = await this._serviceProviderBulkOp.execute();
|
|
173
|
-
this._executed = true;
|
|
174
|
-
this._emitBulkApiCall('execute', { writeConcern: writeConcern });
|
|
175
|
-
return new result_1.BulkWriteResult(!!result.ok, result.nInserted, result.insertedIds, result.nMatched, result.nModified, result.nRemoved, result.nUpserted, result.upserted);
|
|
176
|
-
}
|
|
177
|
-
find(query) {
|
|
178
|
-
(0, helpers_1.assertArgsDefinedType)([query], [true], 'Bulk.find');
|
|
179
|
-
return new BulkFindOp(this._serviceProviderBulkOp.find(query), this);
|
|
180
|
-
}
|
|
181
|
-
insert(document) {
|
|
182
|
-
this._batchCounts.nInsertOps++;
|
|
183
|
-
(0, helpers_1.assertArgsDefinedType)([document], [true], 'Bulk.insert');
|
|
184
|
-
this._serviceProviderBulkOp.insert(document);
|
|
185
|
-
return this;
|
|
186
|
-
}
|
|
187
|
-
toJSON() {
|
|
188
|
-
const batches = this._serviceProviderBulkOp.batches.length;
|
|
189
|
-
return {
|
|
190
|
-
...this._batchCounts,
|
|
191
|
-
nBatches: batches
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
toString() {
|
|
195
|
-
return JSON.stringify(this.toJSON());
|
|
196
|
-
}
|
|
197
|
-
getOperations() {
|
|
198
|
-
if (!this._executed) {
|
|
199
|
-
throw new errors_1.MongoshInvalidInputError('Cannot call getOperations on an unexecuted Bulk operation', errors_1.CommonErrors.InvalidOperation);
|
|
200
|
-
}
|
|
201
|
-
return this._serviceProviderBulkOp.batches.map((b) => ({
|
|
202
|
-
originalZeroIndex: b.originalZeroIndex,
|
|
203
|
-
batchType: b.batchType,
|
|
204
|
-
operations: b.operations
|
|
205
|
-
}));
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
__decorate([
|
|
209
|
-
decorators_1.returnsPromise,
|
|
210
|
-
(0, decorators_1.apiVersions)([1])
|
|
211
|
-
], Bulk.prototype, "execute", null);
|
|
212
|
-
__decorate([
|
|
213
|
-
(0, decorators_1.returnType)('BulkFindOp'),
|
|
214
|
-
(0, decorators_1.apiVersions)([1])
|
|
215
|
-
], Bulk.prototype, "find", null);
|
|
216
|
-
__decorate([
|
|
217
|
-
(0, decorators_1.returnType)('Bulk'),
|
|
218
|
-
(0, decorators_1.apiVersions)([1])
|
|
219
|
-
], Bulk.prototype, "insert", null);
|
|
220
|
-
Bulk = __decorate([
|
|
221
|
-
decorators_1.shellApiClassDefault
|
|
222
|
-
], Bulk);
|
|
223
|
-
exports.default = Bulk;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BulkFindOp = void 0;
|
|
10
|
+
const decorators_1 = require("./decorators");
|
|
11
|
+
const errors_1 = require("@qp-mongosh/errors");
|
|
12
|
+
const enums_1 = require("./enums");
|
|
13
|
+
const helpers_1 = require("./helpers");
|
|
14
|
+
const result_1 = require("./result");
|
|
15
|
+
let BulkFindOp = class BulkFindOp extends decorators_1.ShellApiWithMongoClass {
|
|
16
|
+
constructor(innerFind, parentBulk) {
|
|
17
|
+
super();
|
|
18
|
+
this._serviceProviderBulkFindOp = innerFind;
|
|
19
|
+
this._parentBulk = parentBulk;
|
|
20
|
+
}
|
|
21
|
+
get _mongo() {
|
|
22
|
+
return this._parentBulk._mongo;
|
|
23
|
+
}
|
|
24
|
+
[enums_1.asPrintable]() {
|
|
25
|
+
return 'BulkFindOp';
|
|
26
|
+
}
|
|
27
|
+
collation(spec) {
|
|
28
|
+
this._serviceProviderBulkFindOp.collation(spec);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
arrayFilters(filters) {
|
|
32
|
+
this._serviceProviderBulkFindOp.arrayFilters(filters);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
hint(hintDoc) {
|
|
36
|
+
(0, helpers_1.assertArgsDefinedType)([hintDoc], [true], 'BulkFindOp.hint');
|
|
37
|
+
this._hint = hintDoc;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
delete() {
|
|
41
|
+
this._parentBulk._batchCounts.nRemoveOps++;
|
|
42
|
+
this._serviceProviderBulkFindOp.delete();
|
|
43
|
+
return this._parentBulk;
|
|
44
|
+
}
|
|
45
|
+
deleteOne() {
|
|
46
|
+
this._parentBulk._batchCounts.nRemoveOps++;
|
|
47
|
+
this._serviceProviderBulkFindOp.deleteOne();
|
|
48
|
+
return this._parentBulk;
|
|
49
|
+
}
|
|
50
|
+
remove() {
|
|
51
|
+
return this.delete();
|
|
52
|
+
}
|
|
53
|
+
removeOne() {
|
|
54
|
+
return this.deleteOne();
|
|
55
|
+
}
|
|
56
|
+
replaceOne(replacement) {
|
|
57
|
+
this._parentBulk._batchCounts.nUpdateOps++;
|
|
58
|
+
(0, helpers_1.assertArgsDefinedType)([replacement], [true], 'BulkFindOp.replacement');
|
|
59
|
+
const op = { ...replacement };
|
|
60
|
+
if (this._hint) {
|
|
61
|
+
op.hint = this._hint;
|
|
62
|
+
}
|
|
63
|
+
this._serviceProviderBulkFindOp.replaceOne(op);
|
|
64
|
+
return this._parentBulk;
|
|
65
|
+
}
|
|
66
|
+
updateOne(update) {
|
|
67
|
+
this._parentBulk._batchCounts.nUpdateOps++;
|
|
68
|
+
(0, helpers_1.assertArgsDefinedType)([update], [true], 'BulkFindOp.update');
|
|
69
|
+
const op = { ...update };
|
|
70
|
+
if (this._hint) {
|
|
71
|
+
op.hint = this._hint;
|
|
72
|
+
}
|
|
73
|
+
if (this._arrayFilters) {
|
|
74
|
+
op.arrayFilters = this._arrayFilters;
|
|
75
|
+
}
|
|
76
|
+
this._serviceProviderBulkFindOp.updateOne(op);
|
|
77
|
+
return this._parentBulk;
|
|
78
|
+
}
|
|
79
|
+
update(update) {
|
|
80
|
+
this._parentBulk._batchCounts.nUpdateOps++;
|
|
81
|
+
(0, helpers_1.assertArgsDefinedType)([update], [true], 'BulkFindOp.update');
|
|
82
|
+
const op = { ...update };
|
|
83
|
+
if (this._hint) {
|
|
84
|
+
op.hint = this._hint;
|
|
85
|
+
}
|
|
86
|
+
if (this._arrayFilters) {
|
|
87
|
+
op.arrayFilters = this._arrayFilters;
|
|
88
|
+
}
|
|
89
|
+
this._serviceProviderBulkFindOp.update(op);
|
|
90
|
+
return this._parentBulk;
|
|
91
|
+
}
|
|
92
|
+
upsert() {
|
|
93
|
+
this._serviceProviderBulkFindOp.upsert();
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, decorators_1.returnType)('BulkFindOp'),
|
|
99
|
+
(0, decorators_1.apiVersions)([1])
|
|
100
|
+
], BulkFindOp.prototype, "collation", null);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, decorators_1.returnType)('BulkFindOp'),
|
|
103
|
+
(0, decorators_1.apiVersions)([1])
|
|
104
|
+
], BulkFindOp.prototype, "arrayFilters", null);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, decorators_1.returnType)('BulkFindOp'),
|
|
107
|
+
(0, decorators_1.apiVersions)([1])
|
|
108
|
+
], BulkFindOp.prototype, "hint", null);
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, decorators_1.returnType)('Bulk'),
|
|
111
|
+
(0, decorators_1.apiVersions)([1])
|
|
112
|
+
], BulkFindOp.prototype, "delete", null);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, decorators_1.returnType)('Bulk'),
|
|
115
|
+
(0, decorators_1.apiVersions)([1])
|
|
116
|
+
], BulkFindOp.prototype, "deleteOne", null);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, decorators_1.returnType)('Bulk'),
|
|
119
|
+
(0, decorators_1.apiVersions)([1]),
|
|
120
|
+
decorators_1.deprecated
|
|
121
|
+
], BulkFindOp.prototype, "remove", null);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, decorators_1.returnType)('Bulk'),
|
|
124
|
+
(0, decorators_1.apiVersions)([1]),
|
|
125
|
+
decorators_1.deprecated
|
|
126
|
+
], BulkFindOp.prototype, "removeOne", null);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, decorators_1.returnType)('Bulk'),
|
|
129
|
+
(0, decorators_1.apiVersions)([1])
|
|
130
|
+
], BulkFindOp.prototype, "replaceOne", null);
|
|
131
|
+
__decorate([
|
|
132
|
+
(0, decorators_1.returnType)('Bulk'),
|
|
133
|
+
(0, decorators_1.apiVersions)([1])
|
|
134
|
+
], BulkFindOp.prototype, "updateOne", null);
|
|
135
|
+
__decorate([
|
|
136
|
+
(0, decorators_1.returnType)('Bulk')
|
|
137
|
+
], BulkFindOp.prototype, "update", null);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, decorators_1.returnType)('Bulk')
|
|
140
|
+
], BulkFindOp.prototype, "upsert", null);
|
|
141
|
+
BulkFindOp = __decorate([
|
|
142
|
+
decorators_1.shellApiClassDefault
|
|
143
|
+
], BulkFindOp);
|
|
144
|
+
exports.BulkFindOp = BulkFindOp;
|
|
145
|
+
let Bulk = class Bulk extends decorators_1.ShellApiWithMongoClass {
|
|
146
|
+
constructor(collection, innerBulk, ordered = false) {
|
|
147
|
+
super();
|
|
148
|
+
this._collection = collection;
|
|
149
|
+
this._mongo = collection._mongo;
|
|
150
|
+
this._serviceProviderBulkOp = innerBulk;
|
|
151
|
+
this._batchCounts = {
|
|
152
|
+
nInsertOps: 0,
|
|
153
|
+
nUpdateOps: 0,
|
|
154
|
+
nRemoveOps: 0
|
|
155
|
+
};
|
|
156
|
+
this._executed = false;
|
|
157
|
+
this._ordered = ordered;
|
|
158
|
+
}
|
|
159
|
+
[enums_1.asPrintable]() {
|
|
160
|
+
return this.toJSON();
|
|
161
|
+
}
|
|
162
|
+
_emitBulkApiCall(methodName, methodArguments = {}) {
|
|
163
|
+
this._mongo._instanceState.emitApiCallWithArgs({
|
|
164
|
+
method: methodName,
|
|
165
|
+
class: 'Bulk',
|
|
166
|
+
db: this._collection._database._name,
|
|
167
|
+
coll: this._collection._name,
|
|
168
|
+
arguments: methodArguments
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async execute(writeConcern) {
|
|
172
|
+
const { result } = await this._serviceProviderBulkOp.execute();
|
|
173
|
+
this._executed = true;
|
|
174
|
+
this._emitBulkApiCall('execute', { writeConcern: writeConcern });
|
|
175
|
+
return new result_1.BulkWriteResult(!!result.ok, result.nInserted, result.insertedIds, result.nMatched, result.nModified, result.nRemoved, result.nUpserted, result.upserted);
|
|
176
|
+
}
|
|
177
|
+
find(query) {
|
|
178
|
+
(0, helpers_1.assertArgsDefinedType)([query], [true], 'Bulk.find');
|
|
179
|
+
return new BulkFindOp(this._serviceProviderBulkOp.find(query), this);
|
|
180
|
+
}
|
|
181
|
+
insert(document) {
|
|
182
|
+
this._batchCounts.nInsertOps++;
|
|
183
|
+
(0, helpers_1.assertArgsDefinedType)([document], [true], 'Bulk.insert');
|
|
184
|
+
this._serviceProviderBulkOp.insert(document);
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
toJSON() {
|
|
188
|
+
const batches = this._serviceProviderBulkOp.batches.length;
|
|
189
|
+
return {
|
|
190
|
+
...this._batchCounts,
|
|
191
|
+
nBatches: batches
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
toString() {
|
|
195
|
+
return JSON.stringify(this.toJSON());
|
|
196
|
+
}
|
|
197
|
+
getOperations() {
|
|
198
|
+
if (!this._executed) {
|
|
199
|
+
throw new errors_1.MongoshInvalidInputError('Cannot call getOperations on an unexecuted Bulk operation', errors_1.CommonErrors.InvalidOperation);
|
|
200
|
+
}
|
|
201
|
+
return this._serviceProviderBulkOp.batches.map((b) => ({
|
|
202
|
+
originalZeroIndex: b.originalZeroIndex,
|
|
203
|
+
batchType: b.batchType,
|
|
204
|
+
operations: b.operations
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
__decorate([
|
|
209
|
+
decorators_1.returnsPromise,
|
|
210
|
+
(0, decorators_1.apiVersions)([1])
|
|
211
|
+
], Bulk.prototype, "execute", null);
|
|
212
|
+
__decorate([
|
|
213
|
+
(0, decorators_1.returnType)('BulkFindOp'),
|
|
214
|
+
(0, decorators_1.apiVersions)([1])
|
|
215
|
+
], Bulk.prototype, "find", null);
|
|
216
|
+
__decorate([
|
|
217
|
+
(0, decorators_1.returnType)('Bulk'),
|
|
218
|
+
(0, decorators_1.apiVersions)([1])
|
|
219
|
+
], Bulk.prototype, "insert", null);
|
|
220
|
+
Bulk = __decorate([
|
|
221
|
+
decorators_1.shellApiClassDefault
|
|
222
|
+
], Bulk);
|
|
223
|
+
exports.default = Bulk;
|
|
224
224
|
//# sourceMappingURL=bulk.js.map
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { ShellApiWithMongoClass } from './decorators';
|
|
2
|
-
import { ChangeStream, Document, ResumeToken } from '@qp-mongosh/service-provider-core';
|
|
3
|
-
import { CursorIterationResult } from './result';
|
|
4
|
-
import { asPrintable } from './enums';
|
|
5
|
-
import Mongo from './mongo';
|
|
6
|
-
export default class ChangeStreamCursor extends ShellApiWithMongoClass {
|
|
7
|
-
_mongo: Mongo;
|
|
8
|
-
_cursor: ChangeStream<Document>;
|
|
9
|
-
_currentIterationResult: CursorIterationResult | null;
|
|
10
|
-
_on: string;
|
|
11
|
-
constructor(cursor: ChangeStream<Document>, on: string, mongo: Mongo);
|
|
12
|
-
_it(): Promise<CursorIterationResult>;
|
|
13
|
-
[asPrintable](): string;
|
|
14
|
-
close(): Promise<void>;
|
|
15
|
-
hasNext(): Promise<boolean>;
|
|
16
|
-
tryNext(): Promise<Document | null>;
|
|
17
|
-
[Symbol.asyncIterator](): AsyncGenerator<Document, void, unknown>;
|
|
18
|
-
isClosed(): boolean;
|
|
19
|
-
isExhausted(): never;
|
|
20
|
-
itcount(): Promise<number>;
|
|
21
|
-
next(): Promise<Document>;
|
|
22
|
-
getResumeToken(): ResumeToken;
|
|
23
|
-
map(): ChangeStreamCursor;
|
|
24
|
-
forEach(): Promise<void>;
|
|
25
|
-
toArray(): Promise<Document[]>;
|
|
26
|
-
objsLeftInBatch(): void;
|
|
27
|
-
pretty(): ChangeStreamCursor;
|
|
28
|
-
}
|
|
1
|
+
import { ShellApiWithMongoClass } from './decorators';
|
|
2
|
+
import { ChangeStream, Document, ResumeToken } from '@qp-mongosh/service-provider-core';
|
|
3
|
+
import { CursorIterationResult } from './result';
|
|
4
|
+
import { asPrintable } from './enums';
|
|
5
|
+
import Mongo from './mongo';
|
|
6
|
+
export default class ChangeStreamCursor extends ShellApiWithMongoClass {
|
|
7
|
+
_mongo: Mongo;
|
|
8
|
+
_cursor: ChangeStream<Document>;
|
|
9
|
+
_currentIterationResult: CursorIterationResult | null;
|
|
10
|
+
_on: string;
|
|
11
|
+
constructor(cursor: ChangeStream<Document>, on: string, mongo: Mongo);
|
|
12
|
+
_it(): Promise<CursorIterationResult>;
|
|
13
|
+
[asPrintable](): string;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
hasNext(): Promise<boolean>;
|
|
16
|
+
tryNext(): Promise<Document | null>;
|
|
17
|
+
[Symbol.asyncIterator](): AsyncGenerator<Document, void, unknown>;
|
|
18
|
+
isClosed(): boolean;
|
|
19
|
+
isExhausted(): never;
|
|
20
|
+
itcount(): Promise<number>;
|
|
21
|
+
next(): Promise<Document>;
|
|
22
|
+
getResumeToken(): ResumeToken;
|
|
23
|
+
map(): ChangeStreamCursor;
|
|
24
|
+
forEach(): Promise<void>;
|
|
25
|
+
toArray(): Promise<Document[]>;
|
|
26
|
+
objsLeftInBatch(): void;
|
|
27
|
+
pretty(): ChangeStreamCursor;
|
|
28
|
+
}
|