@resolveio/server-lib 9.0.25 → 9.0.27
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/collections/app-status.collection.js +1 -1
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +1 -1
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +1 -1
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +1 -1
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +1 -1
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +1 -1
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +1 -1
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +1 -1
- package/collections/file.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +1 -1
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +1 -1
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +1 -1
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +1 -1
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +1 -1
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +1 -1
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +1 -1
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +1 -1
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +1 -1
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +1 -1
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +1 -1
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +1 -1
- package/collections/notification.collection.js.map +1 -1
- package/collections/queue-flag.collection.js +1 -1
- package/collections/queue-flag.collection.js.map +1 -1
- package/collections/queue-method.collection.js +1 -1
- package/collections/queue-method.collection.js.map +1 -1
- package/collections/queue-response.collection.js +1 -1
- package/collections/queue-response.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +1 -1
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +1 -1
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +1 -1
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +1 -1
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +1 -1
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +1 -1
- package/collections/user.collection.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/managers/method.manager.js +1 -1
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.d.ts +22 -6
- package/managers/mongo.manager.js +285 -77
- package/managers/mongo.manager.js.map +1 -1
- package/managers/queue-method.manager.js +1 -1
- package/managers/queue-method.manager.js.map +1 -1
- package/managers/subscription.manager.js +2 -2
- package/managers/subscription.manager.js.map +1 -1
- package/methods/collections.js +22 -22
- package/methods/collections.js.map +1 -1
- package/package.json +1 -1
- package/server-app.js +10 -24
- package/server-app.js.map +1 -1
|
@@ -61,7 +61,10 @@ var scmp = require('scmp');
|
|
|
61
61
|
var MongoManager = /** @class */ (function () {
|
|
62
62
|
function MongoManager(mainServer) {
|
|
63
63
|
this._collections = [];
|
|
64
|
+
this._mongoQueue = [];
|
|
65
|
+
this._mongoQueueId = 0;
|
|
64
66
|
this._server = mainServer;
|
|
67
|
+
this.runQueue();
|
|
65
68
|
}
|
|
66
69
|
MongoManager.prototype.registerCollection = function (collection) {
|
|
67
70
|
this._collections.push(collection);
|
|
@@ -72,6 +75,83 @@ var MongoManager = /** @class */ (function () {
|
|
|
72
75
|
MongoManager.prototype.collection = function (collectionName) {
|
|
73
76
|
return this._collections.filter(function (a) { return a.collectionName === collectionName; })[0];
|
|
74
77
|
};
|
|
78
|
+
MongoManager.prototype.addToQueue = function (mongoQueue) {
|
|
79
|
+
var _mongoQueue = this._mongoQueue.filter(function (a) { return a.name_collection === mongoQueue.name_collection && a.name_function === mongoQueue.name_function && a.name_function_addt === mongoQueue.name_function_addt && JSON.stringify(a.data_function) === JSON.stringify(mongoQueue.data_function) && JSON.stringify(a.data_function_addt) === JSON.stringify(mongoQueue.data_function_addt); })[0];
|
|
80
|
+
if (_mongoQueue) {
|
|
81
|
+
if (!_mongoQueue.running) {
|
|
82
|
+
_mongoQueue.cbs.push(mongoQueue.cbs[0]);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
_mongoQueue.cbs_next.push(mongoQueue.cbs[0]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
mongoQueue._id = this._mongoQueueId;
|
|
90
|
+
this._mongoQueueId += 1;
|
|
91
|
+
this._mongoQueue.push(mongoQueue);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
MongoManager.prototype.runQueue = function () {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var _this = this;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
setInterval(function () {
|
|
99
|
+
var _a, _b, _c;
|
|
100
|
+
if (_this._mongoQueue.filter(function (a) { return !a.running; }).length) {
|
|
101
|
+
var mongoQueue_1 = _this._mongoQueue.filter(function (a) { return !a.running; })[0];
|
|
102
|
+
mongoQueue_1.running = true;
|
|
103
|
+
if (!mongoQueue_1.name_function_addt) {
|
|
104
|
+
(_a = index_1.ResolveIOServer.getMainDB().collection(mongoQueue_1.name_collection))[mongoQueue_1.name_function].apply(_a, mongoQueue_1.data_function).then(function (res) {
|
|
105
|
+
mongoQueue_1.cbs.forEach(function (cb) {
|
|
106
|
+
cb(null, res);
|
|
107
|
+
});
|
|
108
|
+
if (mongoQueue_1.cbs_next.length) {
|
|
109
|
+
mongoQueue_1.running = false;
|
|
110
|
+
mongoQueue_1.cbs = mongoQueue_1.cbs_next;
|
|
111
|
+
mongoQueue_1.cbs_next = [];
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id), 1);
|
|
115
|
+
}
|
|
116
|
+
}, function (err) {
|
|
117
|
+
mongoQueue_1.cbs.forEach(function (cb) {
|
|
118
|
+
cb(err, null);
|
|
119
|
+
});
|
|
120
|
+
mongoQueue_1.cbs_next.forEach(function (cb) {
|
|
121
|
+
cb(err, null);
|
|
122
|
+
});
|
|
123
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id), 1);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
(_b = (_c = index_1.ResolveIOServer.getMainDB().collection(mongoQueue_1.name_collection))[mongoQueue_1.name_function].apply(_c, mongoQueue_1.data_function))[mongoQueue_1.name_function_addt].apply(_b, mongoQueue_1.data_function_addt).then(function (res) {
|
|
128
|
+
mongoQueue_1.cbs.forEach(function (cb) {
|
|
129
|
+
cb(null, res);
|
|
130
|
+
});
|
|
131
|
+
if (mongoQueue_1.cbs_next.length) {
|
|
132
|
+
mongoQueue_1.running = false;
|
|
133
|
+
mongoQueue_1.cbs = mongoQueue_1.cbs_next;
|
|
134
|
+
mongoQueue_1.cbs_next = []; // BUG???
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id), 1);
|
|
138
|
+
}
|
|
139
|
+
}, function (err) {
|
|
140
|
+
mongoQueue_1.cbs.forEach(function (cb) {
|
|
141
|
+
cb(err, null);
|
|
142
|
+
});
|
|
143
|
+
mongoQueue_1.cbs_next.forEach(function (cb) {
|
|
144
|
+
cb(err, null);
|
|
145
|
+
});
|
|
146
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id), 1);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, 10);
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
};
|
|
75
155
|
return MongoManager;
|
|
76
156
|
}());
|
|
77
157
|
exports.MongoManager = MongoManager;
|
|
@@ -133,13 +213,53 @@ var Collection = /** @class */ (function () {
|
|
|
133
213
|
index_1.ResolveIOServer.getMainServer().getMongoManager().registerCollection(_this);
|
|
134
214
|
clearInterval(interval);
|
|
135
215
|
}
|
|
136
|
-
},
|
|
216
|
+
}, 1);
|
|
137
217
|
}
|
|
138
218
|
Collection.prototype.aggregate = function (pipeline, options) {
|
|
139
|
-
|
|
219
|
+
var _this = this;
|
|
220
|
+
return new Promise(function (resolve, reject) {
|
|
221
|
+
index_1.ResolveIOServer.getMainServer().getMongoManager().addToQueue({
|
|
222
|
+
_id: 0,
|
|
223
|
+
name_collection: _this.collectionName,
|
|
224
|
+
name_function: 'aggregate',
|
|
225
|
+
name_function_addt: 'toArray',
|
|
226
|
+
data_function: [pipeline, options],
|
|
227
|
+
data_function_addt: [],
|
|
228
|
+
cbs: [function (err, res) {
|
|
229
|
+
if (err) {
|
|
230
|
+
reject(err);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
resolve(res);
|
|
234
|
+
}
|
|
235
|
+
}],
|
|
236
|
+
cbs_next: [],
|
|
237
|
+
running: false
|
|
238
|
+
});
|
|
239
|
+
});
|
|
140
240
|
};
|
|
141
241
|
Collection.prototype.aggregateCount = function (pipeline, options) {
|
|
142
|
-
|
|
242
|
+
var _this = this;
|
|
243
|
+
return new Promise(function (resolve, reject) {
|
|
244
|
+
index_1.ResolveIOServer.getMainServer().getMongoManager().addToQueue({
|
|
245
|
+
_id: 0,
|
|
246
|
+
name_collection: _this.collectionName,
|
|
247
|
+
name_function: 'aggregate',
|
|
248
|
+
name_function_addt: 'count',
|
|
249
|
+
data_function: [pipeline, options],
|
|
250
|
+
data_function_addt: [],
|
|
251
|
+
cbs: [function (err, res) {
|
|
252
|
+
if (err) {
|
|
253
|
+
reject(err);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
resolve(res);
|
|
257
|
+
}
|
|
258
|
+
}],
|
|
259
|
+
cbs_next: [],
|
|
260
|
+
running: false
|
|
261
|
+
});
|
|
262
|
+
});
|
|
143
263
|
};
|
|
144
264
|
Collection.prototype.aggregateCursor = function (pipeline, options) {
|
|
145
265
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).aggregate(pipeline, options);
|
|
@@ -165,8 +285,9 @@ var Collection = /** @class */ (function () {
|
|
|
165
285
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).createIndexes(indexSpecs, options);
|
|
166
286
|
};
|
|
167
287
|
Collection.prototype.deleteMany = function (filter, options) {
|
|
288
|
+
var _this = this;
|
|
168
289
|
if (filter === void 0) { filter = {}; }
|
|
169
|
-
return __awaiter(
|
|
290
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
170
291
|
var docs;
|
|
171
292
|
var _this = this;
|
|
172
293
|
return __generator(this, function (_a) {
|
|
@@ -191,14 +312,24 @@ var Collection = /** @class */ (function () {
|
|
|
191
312
|
});
|
|
192
313
|
});
|
|
193
314
|
_a.label = 2;
|
|
194
|
-
case 2:
|
|
315
|
+
case 2:
|
|
316
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteMany(filter, options).then(function (res) {
|
|
317
|
+
if (res.result.ok) {
|
|
318
|
+
resolve(res.deletedCount);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
reject(res.result.ok);
|
|
322
|
+
}
|
|
323
|
+
}, function (err) { return reject(err); });
|
|
324
|
+
return [2 /*return*/];
|
|
195
325
|
}
|
|
196
326
|
});
|
|
197
|
-
});
|
|
327
|
+
}); });
|
|
198
328
|
};
|
|
199
329
|
Collection.prototype.deleteOne = function (filter, options) {
|
|
330
|
+
var _this = this;
|
|
200
331
|
if (filter === void 0) { filter = {}; }
|
|
201
|
-
return __awaiter(
|
|
332
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
202
333
|
var doc;
|
|
203
334
|
return __generator(this, function (_a) {
|
|
204
335
|
switch (_a.label) {
|
|
@@ -222,10 +353,19 @@ var Collection = /** @class */ (function () {
|
|
|
222
353
|
});
|
|
223
354
|
}
|
|
224
355
|
_a.label = 2;
|
|
225
|
-
case 2:
|
|
356
|
+
case 2:
|
|
357
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteOne(filter, options).then(function (res) {
|
|
358
|
+
if (res.result.ok) {
|
|
359
|
+
resolve(res.deletedCount);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
reject(res.result.ok);
|
|
363
|
+
}
|
|
364
|
+
}, function (err) { return reject(err); });
|
|
365
|
+
return [2 /*return*/];
|
|
226
366
|
}
|
|
227
367
|
});
|
|
228
|
-
});
|
|
368
|
+
}); });
|
|
229
369
|
};
|
|
230
370
|
Collection.prototype.distinct = function (key, filter, options) {
|
|
231
371
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).distinct(key, filter, options);
|
|
@@ -240,38 +380,44 @@ var Collection = /** @class */ (function () {
|
|
|
240
380
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).dropIndexes(options);
|
|
241
381
|
};
|
|
242
382
|
Collection.prototype.find = function (filter, options) {
|
|
383
|
+
var _this = this;
|
|
243
384
|
if (filter === void 0) { filter = {}; }
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
385
|
+
return new Promise(function (resolve, reject) {
|
|
386
|
+
if (_this.createLogs) {
|
|
387
|
+
log_collection_1.Logs.create({
|
|
388
|
+
_id: objectIdHexString(),
|
|
389
|
+
type: 'query',
|
|
390
|
+
collection: _this.collectionName,
|
|
391
|
+
id_document: '',
|
|
392
|
+
payload: common_1.getBinarySize(JSON.stringify([filter, options])) < 200000 ? JSON.stringify([filter, options], null, 2) : 'Too Big',
|
|
393
|
+
method: 'find',
|
|
394
|
+
id_user: '',
|
|
395
|
+
user: '',
|
|
396
|
+
messageId: '',
|
|
397
|
+
route: ''
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
index_1.ResolveIOServer.getMainServer().getMongoManager().addToQueue({
|
|
401
|
+
_id: 0,
|
|
402
|
+
name_collection: _this.collectionName,
|
|
403
|
+
name_function: 'find',
|
|
404
|
+
name_function_addt: 'toArray',
|
|
405
|
+
data_function: [filter, options],
|
|
406
|
+
data_function_addt: [],
|
|
407
|
+
cbs: [function (err, res) {
|
|
408
|
+
if (err) {
|
|
409
|
+
reject(err);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
resolve(res);
|
|
413
|
+
}
|
|
414
|
+
}],
|
|
415
|
+
cbs_next: [],
|
|
416
|
+
running: false
|
|
256
417
|
});
|
|
257
|
-
}
|
|
258
|
-
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options).toArray();
|
|
418
|
+
});
|
|
259
419
|
};
|
|
260
420
|
Collection.prototype.findById = function (id, options) {
|
|
261
|
-
if (this.createLogs) {
|
|
262
|
-
log_collection_1.Logs.create({
|
|
263
|
-
_id: objectIdHexString(),
|
|
264
|
-
type: 'query',
|
|
265
|
-
collection: this.collectionName,
|
|
266
|
-
id_document: id,
|
|
267
|
-
payload: common_1.getBinarySize(JSON.stringify([id, options])) < 200000 ? JSON.stringify([id, options], null, 2) : 'Too Big',
|
|
268
|
-
method: 'findById',
|
|
269
|
-
id_user: '',
|
|
270
|
-
user: '',
|
|
271
|
-
messageId: '',
|
|
272
|
-
route: ''
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
421
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOne({ _id: id }, options);
|
|
276
422
|
};
|
|
277
423
|
Collection.prototype.findCount = function (filter, options) {
|
|
@@ -301,28 +447,48 @@ var Collection = /** @class */ (function () {
|
|
|
301
447
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options).stream(streamOptions);
|
|
302
448
|
};
|
|
303
449
|
Collection.prototype.findOne = function (filter, options) {
|
|
450
|
+
var _this = this;
|
|
304
451
|
if (filter === void 0) { filter = {}; }
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
452
|
+
return new Promise(function (resolve, reject) {
|
|
453
|
+
if (_this.createLogs) {
|
|
454
|
+
log_collection_1.Logs.create({
|
|
455
|
+
_id: objectIdHexString(),
|
|
456
|
+
type: 'query',
|
|
457
|
+
collection: _this.collectionName,
|
|
458
|
+
id_document: '',
|
|
459
|
+
payload: common_1.getBinarySize(JSON.stringify([filter, options])) < 200000 ? JSON.stringify([filter, options], null, 2) : 'Too Big',
|
|
460
|
+
method: 'findOne',
|
|
461
|
+
id_user: '',
|
|
462
|
+
user: '',
|
|
463
|
+
messageId: '',
|
|
464
|
+
route: ''
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
index_1.ResolveIOServer.getMainServer().getMongoManager().addToQueue({
|
|
468
|
+
_id: 0,
|
|
469
|
+
name_collection: _this.collectionName,
|
|
470
|
+
name_function: 'findOne',
|
|
471
|
+
name_function_addt: '',
|
|
472
|
+
data_function: [filter, options],
|
|
473
|
+
data_function_addt: [],
|
|
474
|
+
cbs: [function (err, res) {
|
|
475
|
+
if (err) {
|
|
476
|
+
reject(err);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
resolve(res);
|
|
480
|
+
}
|
|
481
|
+
}],
|
|
482
|
+
cbs_next: [],
|
|
483
|
+
running: false
|
|
317
484
|
});
|
|
318
|
-
}
|
|
319
|
-
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOne(filter, options);
|
|
485
|
+
});
|
|
320
486
|
};
|
|
321
487
|
Collection.prototype.findOneAndDelete = function (filter, options) {
|
|
488
|
+
var _this = this;
|
|
322
489
|
if (filter === void 0) { filter = {}; }
|
|
323
|
-
return __awaiter(
|
|
490
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
324
491
|
var doc;
|
|
325
|
-
var _this = this;
|
|
326
492
|
return __generator(this, function (_a) {
|
|
327
493
|
switch (_a.label) {
|
|
328
494
|
case 0:
|
|
@@ -345,16 +511,19 @@ var Collection = /** @class */ (function () {
|
|
|
345
511
|
});
|
|
346
512
|
}
|
|
347
513
|
_a.label = 2;
|
|
348
|
-
case 2:
|
|
349
|
-
|
|
514
|
+
case 2:
|
|
515
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndDelete(filter, options).then(function (res) {
|
|
516
|
+
if (res.ok) {
|
|
350
517
|
resolve(res.value);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
reject(res.lastErrorObject);
|
|
521
|
+
}
|
|
522
|
+
}, function (err) { return reject(err); });
|
|
523
|
+
return [2 /*return*/];
|
|
355
524
|
}
|
|
356
525
|
});
|
|
357
|
-
});
|
|
526
|
+
}); });
|
|
358
527
|
};
|
|
359
528
|
Collection.prototype.findOneAndReplace = function (filter, replacement, options) {
|
|
360
529
|
var _this = this;
|
|
@@ -386,10 +555,13 @@ var Collection = /** @class */ (function () {
|
|
|
386
555
|
_a.label = 2;
|
|
387
556
|
case 2:
|
|
388
557
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndReplace(filter, replacement, options).then(function (res) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
558
|
+
if (res.ok) {
|
|
559
|
+
resolve(res.value);
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
reject(res.lastErrorObject);
|
|
563
|
+
}
|
|
564
|
+
}, function (err) { return reject(err); });
|
|
393
565
|
return [2 /*return*/];
|
|
394
566
|
}
|
|
395
567
|
});
|
|
@@ -430,10 +602,13 @@ var Collection = /** @class */ (function () {
|
|
|
430
602
|
_a.label = 2;
|
|
431
603
|
case 2:
|
|
432
604
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndUpdate(filter, update, options).then(function (res) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
605
|
+
if (res.ok) {
|
|
606
|
+
resolve(res.value);
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
reject(res.lastErrorObject);
|
|
610
|
+
}
|
|
611
|
+
}, function (err) { return reject(err); });
|
|
437
612
|
return [2 /*return*/];
|
|
438
613
|
}
|
|
439
614
|
});
|
|
@@ -525,7 +700,8 @@ var Collection = /** @class */ (function () {
|
|
|
525
700
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).rename(newName, options);
|
|
526
701
|
};
|
|
527
702
|
Collection.prototype.replaceOne = function (filter, replacement, options) {
|
|
528
|
-
|
|
703
|
+
var _this = this;
|
|
704
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
529
705
|
var doc;
|
|
530
706
|
return __generator(this, function (_a) {
|
|
531
707
|
switch (_a.label) {
|
|
@@ -549,16 +725,28 @@ var Collection = /** @class */ (function () {
|
|
|
549
725
|
});
|
|
550
726
|
}
|
|
551
727
|
_a.label = 2;
|
|
552
|
-
case 2:
|
|
728
|
+
case 2:
|
|
729
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
730
|
+
if (res.result.ok) {
|
|
731
|
+
resolve(res.result.nModified);
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
reject(res.result.ok);
|
|
735
|
+
}
|
|
736
|
+
}, function (err) {
|
|
737
|
+
reject(err);
|
|
738
|
+
});
|
|
739
|
+
return [2 /*return*/];
|
|
553
740
|
}
|
|
554
741
|
});
|
|
555
|
-
});
|
|
742
|
+
}); });
|
|
556
743
|
};
|
|
557
744
|
Collection.prototype.stats = function (options) {
|
|
558
745
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).stats(options);
|
|
559
746
|
};
|
|
560
747
|
Collection.prototype.updateMany = function (filter, update, options) {
|
|
561
|
-
|
|
748
|
+
var _this = this;
|
|
749
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
562
750
|
var docs;
|
|
563
751
|
var _this = this;
|
|
564
752
|
return __generator(this, function (_a) {
|
|
@@ -589,13 +777,24 @@ var Collection = /** @class */ (function () {
|
|
|
589
777
|
});
|
|
590
778
|
});
|
|
591
779
|
_a.label = 2;
|
|
592
|
-
case 2:
|
|
780
|
+
case 2:
|
|
781
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateMany(filter, update, options).then(function (res) {
|
|
782
|
+
if (res.result.ok) {
|
|
783
|
+
resolve(res.result.nModified);
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
reject(res.result.ok);
|
|
787
|
+
}
|
|
788
|
+
}, function (err) { return reject(err); });
|
|
789
|
+
return [2 /*return*/];
|
|
593
790
|
}
|
|
594
791
|
});
|
|
595
|
-
});
|
|
792
|
+
}); });
|
|
793
|
+
return;
|
|
596
794
|
};
|
|
597
795
|
Collection.prototype.updateOne = function (filter, update, options) {
|
|
598
|
-
|
|
796
|
+
var _this = this;
|
|
797
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
599
798
|
var doc;
|
|
600
799
|
return __generator(this, function (_a) {
|
|
601
800
|
switch (_a.label) {
|
|
@@ -625,10 +824,19 @@ var Collection = /** @class */ (function () {
|
|
|
625
824
|
});
|
|
626
825
|
}
|
|
627
826
|
_a.label = 2;
|
|
628
|
-
case 2:
|
|
827
|
+
case 2:
|
|
828
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
829
|
+
if (res.result.ok) {
|
|
830
|
+
resolve(res.result.nModified);
|
|
831
|
+
}
|
|
832
|
+
else {
|
|
833
|
+
reject(res.result.ok);
|
|
834
|
+
}
|
|
835
|
+
}, function (err) { return reject(err); });
|
|
836
|
+
return [2 /*return*/];
|
|
629
837
|
}
|
|
630
838
|
});
|
|
631
|
-
});
|
|
839
|
+
}); });
|
|
632
840
|
};
|
|
633
841
|
Collection.prototype.watchCollection = function (options) {
|
|
634
842
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).watch(options);
|