@resolveio/server-lib 9.0.13 → 9.0.15
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/log.collection.js +11 -18
- package/collections/log.collection.js.map +1 -1
- package/managers/method.manager.js +21 -37
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.d.ts +13 -13
- package/managers/mongo.manager.js +357 -57
- package/managers/mongo.manager.js.map +1 -1
- package/managers/queue-method.manager.js +21 -37
- package/managers/queue-method.manager.js.map +1 -1
- package/methods/collections.js +0 -208
- package/methods/collections.js.map +1 -1
- package/methods/logs.js +3 -4
- package/methods/logs.js.map +1 -1
- package/models/log.model.d.ts +5 -6
- package/models/log.model.js.map +1 -1
- package/package.json +1 -1
- package/publications/logs.js +75 -2
- package/publications/logs.js.map +1 -1
- package/server-app.js +12 -32
- package/server-app.js.map +1 -1
|
@@ -55,6 +55,7 @@ var mongodb_1 = require("mongodb");
|
|
|
55
55
|
var index_1 = require("../index");
|
|
56
56
|
var user_collection_1 = require("../collections/user.collection");
|
|
57
57
|
var common_1 = require("../util/common");
|
|
58
|
+
var log_collection_1 = require("../collections/log.collection");
|
|
58
59
|
var crypto = require('crypto');
|
|
59
60
|
var scmp = require('scmp');
|
|
60
61
|
var MongoManager = /** @class */ (function () {
|
|
@@ -144,9 +145,9 @@ var Collection = /** @class */ (function () {
|
|
|
144
145
|
Collection.prototype.aggregateStream = function (pipeline, options) {
|
|
145
146
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).aggregate(pipeline, options).stream();
|
|
146
147
|
};
|
|
147
|
-
Collection.prototype.countDocuments = function (
|
|
148
|
-
if (
|
|
149
|
-
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).countDocuments(
|
|
148
|
+
Collection.prototype.countDocuments = function (filter, options) {
|
|
149
|
+
if (filter === void 0) { filter = {}; }
|
|
150
|
+
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).countDocuments(filter, options);
|
|
150
151
|
};
|
|
151
152
|
Collection.prototype.create = function (f_docs, options) {
|
|
152
153
|
var docs = [];
|
|
@@ -161,16 +162,65 @@ var Collection = /** @class */ (function () {
|
|
|
161
162
|
Collection.prototype.createIndexes = function (indexSpecs, options) {
|
|
162
163
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).createIndexes(indexSpecs, options);
|
|
163
164
|
};
|
|
164
|
-
Collection.prototype.deleteMany = function (
|
|
165
|
-
if (
|
|
166
|
-
return
|
|
165
|
+
Collection.prototype.deleteMany = function (filter, options) {
|
|
166
|
+
if (filter === void 0) { filter = {}; }
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var docs;
|
|
169
|
+
var _this = this;
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
switch (_a.label) {
|
|
172
|
+
case 0: return [4 /*yield*/, this.find(filter)];
|
|
173
|
+
case 1:
|
|
174
|
+
docs = _a.sent();
|
|
175
|
+
docs.forEach(function (doc) {
|
|
176
|
+
log_collection_1.Logs.create({
|
|
177
|
+
_id: objectIdHexString(),
|
|
178
|
+
type: 'document',
|
|
179
|
+
collection: _this.collectionName,
|
|
180
|
+
id_document: doc['_id'],
|
|
181
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, filter, options])) < 200000 ? JSON.stringify([doc, filter, options], null, 2) : 'Too Big',
|
|
182
|
+
method: 'deleteMany',
|
|
183
|
+
id_user: '',
|
|
184
|
+
user: '',
|
|
185
|
+
messageId: '',
|
|
186
|
+
route: ''
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
return [2 /*return*/, index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteMany(filter, options)];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
167
193
|
};
|
|
168
|
-
Collection.prototype.deleteOne = function (
|
|
169
|
-
if (
|
|
170
|
-
return
|
|
194
|
+
Collection.prototype.deleteOne = function (filter, options) {
|
|
195
|
+
if (filter === void 0) { filter = {}; }
|
|
196
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
+
var doc;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0: return [4 /*yield*/, this.findOne(filter)];
|
|
201
|
+
case 1:
|
|
202
|
+
doc = _a.sent();
|
|
203
|
+
if (doc) {
|
|
204
|
+
log_collection_1.Logs.create({
|
|
205
|
+
_id: objectIdHexString(),
|
|
206
|
+
type: 'document',
|
|
207
|
+
collection: this.collectionName,
|
|
208
|
+
id_document: doc['_id'],
|
|
209
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, filter, options])) < 200000 ? JSON.stringify([doc, filter, options], null, 2) : 'Too Big',
|
|
210
|
+
method: 'deleteMany',
|
|
211
|
+
id_user: '',
|
|
212
|
+
user: '',
|
|
213
|
+
messageId: '',
|
|
214
|
+
route: ''
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return [2 /*return*/, index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteOne(filter, options)];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
171
221
|
};
|
|
172
|
-
Collection.prototype.distinct = function (key,
|
|
173
|
-
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).distinct(key,
|
|
222
|
+
Collection.prototype.distinct = function (key, filter, options) {
|
|
223
|
+
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).distinct(key, filter, options);
|
|
174
224
|
};
|
|
175
225
|
Collection.prototype.drop = function (options) {
|
|
176
226
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).drop(options);
|
|
@@ -181,61 +231,188 @@ var Collection = /** @class */ (function () {
|
|
|
181
231
|
Collection.prototype.dropIndexes = function (options) {
|
|
182
232
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).dropIndexes(options);
|
|
183
233
|
};
|
|
184
|
-
Collection.prototype.find = function (
|
|
185
|
-
if (
|
|
186
|
-
|
|
234
|
+
Collection.prototype.find = function (filter, options) {
|
|
235
|
+
if (filter === void 0) { filter = {}; }
|
|
236
|
+
log_collection_1.Logs.create({
|
|
237
|
+
_id: objectIdHexString(),
|
|
238
|
+
type: 'query',
|
|
239
|
+
collection: this.collectionName,
|
|
240
|
+
id_document: '',
|
|
241
|
+
payload: common_1.getBinarySize(JSON.stringify([filter, options])) < 200000 ? JSON.stringify([filter, options], null, 2) : 'Too Big',
|
|
242
|
+
method: 'find',
|
|
243
|
+
id_user: '',
|
|
244
|
+
user: '',
|
|
245
|
+
messageId: '',
|
|
246
|
+
route: ''
|
|
247
|
+
});
|
|
248
|
+
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options).toArray();
|
|
187
249
|
};
|
|
188
250
|
Collection.prototype.findById = function (id, options) {
|
|
251
|
+
log_collection_1.Logs.create({
|
|
252
|
+
_id: objectIdHexString(),
|
|
253
|
+
type: 'query',
|
|
254
|
+
collection: this.collectionName,
|
|
255
|
+
id_document: id,
|
|
256
|
+
payload: common_1.getBinarySize(JSON.stringify([id, options])) < 200000 ? JSON.stringify([id, options], null, 2) : 'Too Big',
|
|
257
|
+
method: 'findById',
|
|
258
|
+
id_user: '',
|
|
259
|
+
user: '',
|
|
260
|
+
messageId: '',
|
|
261
|
+
route: ''
|
|
262
|
+
});
|
|
189
263
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOne({ _id: id }, options);
|
|
190
264
|
};
|
|
191
|
-
Collection.prototype.findCount = function (
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).
|
|
265
|
+
Collection.prototype.findCount = function (filter, options) {
|
|
266
|
+
if (filter === void 0) { filter = {}; }
|
|
267
|
+
log_collection_1.Logs.create({
|
|
268
|
+
_id: objectIdHexString(),
|
|
269
|
+
type: 'query',
|
|
270
|
+
collection: this.collectionName,
|
|
271
|
+
id_document: '',
|
|
272
|
+
payload: common_1.getBinarySize(JSON.stringify([filter, options])) < 200000 ? JSON.stringify([filter, options], null, 2) : 'Too Big',
|
|
273
|
+
method: 'findCount',
|
|
274
|
+
id_user: '',
|
|
275
|
+
user: '',
|
|
276
|
+
messageId: '',
|
|
277
|
+
route: ''
|
|
278
|
+
});
|
|
279
|
+
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options).count();
|
|
280
|
+
};
|
|
281
|
+
Collection.prototype.findCursor = function (filter, options) {
|
|
282
|
+
if (filter === void 0) { filter = {}; }
|
|
283
|
+
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options);
|
|
284
|
+
};
|
|
285
|
+
Collection.prototype.findStream = function (filter, options, streamOptions) {
|
|
286
|
+
if (filter === void 0) { filter = {}; }
|
|
287
|
+
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options).stream(streamOptions);
|
|
288
|
+
};
|
|
289
|
+
Collection.prototype.findOne = function (filter, options) {
|
|
290
|
+
if (filter === void 0) { filter = {}; }
|
|
291
|
+
log_collection_1.Logs.create({
|
|
292
|
+
_id: objectIdHexString(),
|
|
293
|
+
type: 'query',
|
|
294
|
+
collection: this.collectionName,
|
|
295
|
+
id_document: '',
|
|
296
|
+
payload: common_1.getBinarySize(JSON.stringify([filter, options])) < 200000 ? JSON.stringify([filter, options], null, 2) : 'Too Big',
|
|
297
|
+
method: 'findOne',
|
|
298
|
+
id_user: '',
|
|
299
|
+
user: '',
|
|
300
|
+
messageId: '',
|
|
301
|
+
route: ''
|
|
302
|
+
});
|
|
303
|
+
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOne(filter, options);
|
|
206
304
|
};
|
|
207
|
-
Collection.prototype.findOneAndDelete = function (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
305
|
+
Collection.prototype.findOneAndDelete = function (filter, options) {
|
|
306
|
+
if (filter === void 0) { filter = {}; }
|
|
307
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
308
|
+
var doc;
|
|
309
|
+
var _this = this;
|
|
310
|
+
return __generator(this, function (_a) {
|
|
311
|
+
switch (_a.label) {
|
|
312
|
+
case 0: return [4 /*yield*/, this.findOne(filter)];
|
|
313
|
+
case 1:
|
|
314
|
+
doc = _a.sent();
|
|
315
|
+
if (doc) {
|
|
316
|
+
log_collection_1.Logs.create({
|
|
317
|
+
_id: objectIdHexString(),
|
|
318
|
+
type: 'document',
|
|
319
|
+
collection: this.collectionName,
|
|
320
|
+
id_document: doc['_id'],
|
|
321
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, filter, options])) < 200000 ? JSON.stringify([doc, filter, options], null, 2) : 'Too Big',
|
|
322
|
+
method: 'findOneAndDelete',
|
|
323
|
+
id_user: '',
|
|
324
|
+
user: '',
|
|
325
|
+
messageId: '',
|
|
326
|
+
route: ''
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
330
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).findOneAndDelete(filter, options).then(function (res) {
|
|
331
|
+
resolve(res.value);
|
|
332
|
+
}, function (err) {
|
|
333
|
+
reject(err);
|
|
334
|
+
});
|
|
335
|
+
})];
|
|
336
|
+
}
|
|
215
337
|
});
|
|
216
338
|
});
|
|
217
339
|
};
|
|
218
|
-
Collection.prototype.findOneAndReplace = function (
|
|
340
|
+
Collection.prototype.findOneAndReplace = function (filter, replacement, options) {
|
|
219
341
|
var _this = this;
|
|
220
|
-
if (
|
|
221
|
-
return new Promise(function (resolve, reject) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
342
|
+
if (filter === void 0) { filter = {}; }
|
|
343
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
344
|
+
var doc;
|
|
345
|
+
return __generator(this, function (_a) {
|
|
346
|
+
switch (_a.label) {
|
|
347
|
+
case 0:
|
|
348
|
+
replacement['updatedAt'] = new Date();
|
|
349
|
+
return [4 /*yield*/, this.findOne(filter)];
|
|
350
|
+
case 1:
|
|
351
|
+
doc = _a.sent();
|
|
352
|
+
if (doc) {
|
|
353
|
+
log_collection_1.Logs.create({
|
|
354
|
+
_id: objectIdHexString(),
|
|
355
|
+
type: 'document',
|
|
356
|
+
collection: this.collectionName,
|
|
357
|
+
id_document: doc['_id'],
|
|
358
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, filter, replacement, options])) < 200000 ? JSON.stringify([doc, filter, replacement, options], null, 2) : 'Too Big',
|
|
359
|
+
method: 'findOneAndReplace',
|
|
360
|
+
id_user: '',
|
|
361
|
+
user: '',
|
|
362
|
+
messageId: '',
|
|
363
|
+
route: ''
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndReplace(filter, replacement, options).then(function (res) {
|
|
367
|
+
resolve(res.value);
|
|
368
|
+
}, function (err) {
|
|
369
|
+
reject(err);
|
|
370
|
+
});
|
|
371
|
+
return [2 /*return*/];
|
|
372
|
+
}
|
|
226
373
|
});
|
|
227
|
-
});
|
|
374
|
+
}); });
|
|
228
375
|
};
|
|
229
|
-
Collection.prototype.findOneAndUpdate = function (
|
|
376
|
+
Collection.prototype.findOneAndUpdate = function (filter, update, options) {
|
|
230
377
|
var _this = this;
|
|
231
|
-
if (
|
|
232
|
-
return new Promise(function (resolve, reject) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
378
|
+
if (filter === void 0) { filter = {}; }
|
|
379
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
380
|
+
var doc;
|
|
381
|
+
return __generator(this, function (_a) {
|
|
382
|
+
switch (_a.label) {
|
|
383
|
+
case 0:
|
|
384
|
+
if (!update['$set']) {
|
|
385
|
+
update['$set'] = { updatedAt: new Date() };
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
update['$set']['updatedAt'] = new Date();
|
|
389
|
+
}
|
|
390
|
+
return [4 /*yield*/, this.findOne(filter)];
|
|
391
|
+
case 1:
|
|
392
|
+
doc = _a.sent();
|
|
393
|
+
if (doc) {
|
|
394
|
+
log_collection_1.Logs.create({
|
|
395
|
+
_id: objectIdHexString(),
|
|
396
|
+
type: 'document',
|
|
397
|
+
collection: this.collectionName,
|
|
398
|
+
id_document: doc['_id'],
|
|
399
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, filter, update, options])) < 200000 ? JSON.stringify([doc, filter, update, options], null, 2) : 'Too Big',
|
|
400
|
+
method: 'findOneAndUpdate',
|
|
401
|
+
id_user: '',
|
|
402
|
+
user: '',
|
|
403
|
+
messageId: '',
|
|
404
|
+
route: ''
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndUpdate(filter, update, options).then(function (res) {
|
|
408
|
+
resolve(res.value);
|
|
409
|
+
}, function (err) {
|
|
410
|
+
reject(err);
|
|
411
|
+
});
|
|
412
|
+
return [2 /*return*/];
|
|
413
|
+
}
|
|
237
414
|
});
|
|
238
|
-
});
|
|
415
|
+
}); });
|
|
239
416
|
};
|
|
240
417
|
Collection.prototype.indexes = function (options) {
|
|
241
418
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).indexes(options);
|
|
@@ -246,6 +423,26 @@ var Collection = /** @class */ (function () {
|
|
|
246
423
|
Collection.prototype.insertMany = function (docs, options) {
|
|
247
424
|
var _this = this;
|
|
248
425
|
return new Promise(function (resolve, reject) {
|
|
426
|
+
if (_this.timestamps) {
|
|
427
|
+
docs.forEach(function (doc) {
|
|
428
|
+
doc['createdAt'] = new Date();
|
|
429
|
+
doc['updatedAt'] = new Date();
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
docs.forEach(function (doc) {
|
|
433
|
+
log_collection_1.Logs.create({
|
|
434
|
+
_id: objectIdHexString(),
|
|
435
|
+
type: 'document',
|
|
436
|
+
collection: _this.collectionName,
|
|
437
|
+
id_document: doc['_id'],
|
|
438
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, options])) < 200000 ? JSON.stringify([doc, options], null, 2) : 'Too Big',
|
|
439
|
+
method: 'insertMany',
|
|
440
|
+
id_user: '',
|
|
441
|
+
user: '',
|
|
442
|
+
messageId: '',
|
|
443
|
+
route: ''
|
|
444
|
+
});
|
|
445
|
+
});
|
|
249
446
|
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).insertMany(docs, options).then(function (res) {
|
|
250
447
|
if (res.result.ok) {
|
|
251
448
|
resolve(docs);
|
|
@@ -261,6 +458,22 @@ var Collection = /** @class */ (function () {
|
|
|
261
458
|
Collection.prototype.insertOne = function (doc, options) {
|
|
262
459
|
var _this = this;
|
|
263
460
|
return new Promise(function (resolve, reject) {
|
|
461
|
+
if (_this.timestamps) {
|
|
462
|
+
doc['createdAt'] = new Date();
|
|
463
|
+
doc['updatedAt'] = new Date();
|
|
464
|
+
}
|
|
465
|
+
log_collection_1.Logs.create({
|
|
466
|
+
_id: objectIdHexString(),
|
|
467
|
+
type: 'document',
|
|
468
|
+
collection: _this.collectionName,
|
|
469
|
+
id_document: doc['_id'],
|
|
470
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, options])) < 200000 ? JSON.stringify([doc, options], null, 2) : 'Too Big',
|
|
471
|
+
method: 'insertOne',
|
|
472
|
+
id_user: '',
|
|
473
|
+
user: '',
|
|
474
|
+
messageId: '',
|
|
475
|
+
route: ''
|
|
476
|
+
});
|
|
264
477
|
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).insertOne(doc, options).then(function (res) {
|
|
265
478
|
if (res.result.ok) {
|
|
266
479
|
resolve(doc);
|
|
@@ -282,17 +495,104 @@ var Collection = /** @class */ (function () {
|
|
|
282
495
|
Collection.prototype.rename = function (newName, options) {
|
|
283
496
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).rename(newName, options);
|
|
284
497
|
};
|
|
285
|
-
Collection.prototype.replaceOne = function (filter,
|
|
286
|
-
return
|
|
498
|
+
Collection.prototype.replaceOne = function (filter, replacement, options) {
|
|
499
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
500
|
+
var doc;
|
|
501
|
+
return __generator(this, function (_a) {
|
|
502
|
+
switch (_a.label) {
|
|
503
|
+
case 0: return [4 /*yield*/, this.findOne(filter)];
|
|
504
|
+
case 1:
|
|
505
|
+
doc = _a.sent();
|
|
506
|
+
if (doc) {
|
|
507
|
+
log_collection_1.Logs.create({
|
|
508
|
+
_id: objectIdHexString(),
|
|
509
|
+
type: 'document',
|
|
510
|
+
collection: this.collectionName,
|
|
511
|
+
id_document: doc['_id'],
|
|
512
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, filter, replacement, options])) < 200000 ? JSON.stringify([doc, filter, replacement, options], null, 2) : 'Too Big',
|
|
513
|
+
method: 'replaceOne',
|
|
514
|
+
id_user: '',
|
|
515
|
+
user: '',
|
|
516
|
+
messageId: '',
|
|
517
|
+
route: ''
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
return [2 /*return*/, index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options)];
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
});
|
|
287
524
|
};
|
|
288
525
|
Collection.prototype.stats = function (options) {
|
|
289
526
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).stats(options);
|
|
290
527
|
};
|
|
291
528
|
Collection.prototype.updateMany = function (filter, update, options) {
|
|
292
|
-
return
|
|
529
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
530
|
+
var docs;
|
|
531
|
+
var _this = this;
|
|
532
|
+
return __generator(this, function (_a) {
|
|
533
|
+
switch (_a.label) {
|
|
534
|
+
case 0:
|
|
535
|
+
if (!update['$set']) {
|
|
536
|
+
update['$set'] = { updatedAt: new Date() };
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
update['$set']['updatedAt'] = new Date();
|
|
540
|
+
}
|
|
541
|
+
return [4 /*yield*/, this.find(filter)];
|
|
542
|
+
case 1:
|
|
543
|
+
docs = _a.sent();
|
|
544
|
+
docs.forEach(function (doc) {
|
|
545
|
+
log_collection_1.Logs.create({
|
|
546
|
+
_id: objectIdHexString(),
|
|
547
|
+
type: 'document',
|
|
548
|
+
collection: _this.collectionName,
|
|
549
|
+
id_document: doc['_id'],
|
|
550
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, filter, update, options])) < 200000 ? JSON.stringify([doc, filter, update, options], null, 2) : 'Too Big',
|
|
551
|
+
method: 'updateMany',
|
|
552
|
+
id_user: '',
|
|
553
|
+
user: '',
|
|
554
|
+
messageId: '',
|
|
555
|
+
route: ''
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
return [2 /*return*/, index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateMany(filter, update, options)];
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
});
|
|
293
562
|
};
|
|
294
563
|
Collection.prototype.updateOne = function (filter, update, options) {
|
|
295
|
-
return
|
|
564
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
565
|
+
var doc;
|
|
566
|
+
return __generator(this, function (_a) {
|
|
567
|
+
switch (_a.label) {
|
|
568
|
+
case 0:
|
|
569
|
+
if (!update['$set']) {
|
|
570
|
+
update['$set'] = { updatedAt: new Date() };
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
update['$set']['updatedAt'] = new Date();
|
|
574
|
+
}
|
|
575
|
+
return [4 /*yield*/, this.findOne(filter)];
|
|
576
|
+
case 1:
|
|
577
|
+
doc = _a.sent();
|
|
578
|
+
if (doc) {
|
|
579
|
+
log_collection_1.Logs.create({
|
|
580
|
+
_id: objectIdHexString(),
|
|
581
|
+
type: 'document',
|
|
582
|
+
collection: this.collectionName,
|
|
583
|
+
id_document: doc['_id'],
|
|
584
|
+
payload: common_1.getBinarySize(JSON.stringify([doc, filter, update, options])) < 200000 ? JSON.stringify([doc, filter, update, options], null, 2) : 'Too Big',
|
|
585
|
+
method: 'updateOne',
|
|
586
|
+
id_user: '',
|
|
587
|
+
user: '',
|
|
588
|
+
messageId: '',
|
|
589
|
+
route: ''
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
return [2 /*return*/, index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options)];
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
});
|
|
296
596
|
};
|
|
297
597
|
Collection.prototype.watchCollection = function (options) {
|
|
298
598
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).watch(options);
|