@resolveio/server-lib 9.2.18 → 9.2.19
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/client-server-app.js +1 -55
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +1 -40
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +1 -40
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +1 -43
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +1 -71
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +1 -74
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +1 -55
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +1 -50
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +1 -62
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +1 -44
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +1 -53
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +1 -57
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +1 -72
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +1 -58
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +1 -51
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +1 -55
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +1 -57
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +1 -66
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +1 -74
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +1 -68
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +1 -62
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +1 -40
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +1 -93
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +1 -76
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +1 -138
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +1 -79
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +1 -46
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +1 -248
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +1 -161
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +1 -72
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +1 -62
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +1 -697
- package/http/auth.js.map +1 -1
- package/http/health.js +1 -10
- package/http/health.js.map +1 -1
- package/http/home.js +1 -64
- package/http/home.js.map +1 -1
- package/index.js +1 -123
- package/index.js.map +1 -1
- package/managers/cron.manager.js +1 -205
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +1 -599
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1 -1682
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +1 -334
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +1 -867
- package/managers/subscription.manager.js.map +1 -1
- package/managers/subscription.performance.js +1 -100
- package/managers/subscription.performance.js.map +1 -1
- package/methods/accounts.js +1 -224
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +1 -449
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +1 -214
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +1 -526
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +1 -121
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +1 -1284
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +1 -8
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +1 -370
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +1 -384
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +1 -685
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +1 -826
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +1 -263
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +1 -3
- package/models/app-status.model.js.map +1 -1
- package/models/app-version.model.js +1 -3
- package/models/app-version.model.js.map +1 -1
- package/models/billing-logged-in-users.model.js +1 -3
- package/models/billing-logged-in-users.model.js.map +1 -1
- package/models/collection-document.model.js +1 -3
- package/models/collection-document.model.js.map +1 -1
- package/models/counter.model.js +1 -3
- package/models/counter.model.js.map +1 -1
- package/models/cron-job-history.model.js +1 -3
- package/models/cron-job-history.model.js.map +1 -1
- package/models/cron-job.model.js +1 -3
- package/models/cron-job.model.js.map +1 -1
- package/models/dialog.model.js +1 -3
- package/models/dialog.model.js.map +1 -1
- package/models/email-history.model.js +1 -3
- package/models/email-history.model.js.map +1 -1
- package/models/email-verified.model.js +1 -3
- package/models/email-verified.model.js.map +1 -1
- package/models/file.model.js +1 -3
- package/models/file.model.js.map +1 -1
- package/models/flag.model.js +1 -3
- package/models/flag.model.js.map +1 -1
- package/models/log-method-latency.model.js +1 -3
- package/models/log-method-latency.model.js.map +1 -1
- package/models/log-subscription.model.js +1 -3
- package/models/log-subscription.model.js.map +1 -1
- package/models/log.model.js +1 -3
- package/models/log.model.js.map +1 -1
- package/models/logged-in-users.model.js +1 -3
- package/models/logged-in-users.model.js.map +1 -1
- package/models/method-call.model.js +1 -3
- package/models/method-call.model.js.map +1 -1
- package/models/method-response.model.js +1 -3
- package/models/method-response.model.js.map +1 -1
- package/models/method.model.js +1 -3
- package/models/method.model.js.map +1 -1
- package/models/monitor-cpu.model.js +1 -3
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-https-inbound.model.js +1 -3
- package/models/monitor-https-inbound.model.js.map +1 -1
- package/models/monitor-https-outbound.model.js +1 -3
- package/models/monitor-https-outbound.model.js.map +1 -1
- package/models/monitor-memory.model.js +1 -3
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.js +1 -3
- package/models/monitor-mongo.model.js.map +1 -1
- package/models/notification.model.js +1 -3
- package/models/notification.model.js.map +1 -1
- package/models/pagination.model.js +1 -23
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +1 -3
- package/models/permission.model.js.map +1 -1
- package/models/report-builder-dashboard-builder.model.js +1 -3
- package/models/report-builder-dashboard-builder.model.js.map +1 -1
- package/models/report-builder-library.model.js +1 -3
- package/models/report-builder-library.model.js.map +1 -1
- package/models/report-builder-report.model.js +1 -3
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.js +1 -3
- package/models/report-builder.model.js.map +1 -1
- package/models/select-data-label.model.js +1 -3
- package/models/select-data-label.model.js.map +1 -1
- package/models/server-response.model.js +1 -3
- package/models/server-response.model.js.map +1 -1
- package/models/subscription.model.js +1 -3
- package/models/subscription.model.js.map +1 -1
- package/models/support-ticket.model.js +1 -3
- package/models/support-ticket.model.js.map +1 -1
- package/models/user-group.model.js +1 -3
- package/models/user-group.model.js.map +1 -1
- package/models/user-guide.model.js +1 -3
- package/models/user-guide.model.js.map +1 -1
- package/models/user.model.js +1 -3
- package/models/user.model.js.map +1 -1
- package/package.json +2 -1
- package/public_api.js +1 -78
- package/public_api.js.map +1 -1
- package/publications/app-status.js +1 -16
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +1 -16
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +1 -32
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +1 -36
- package/publications/files.js.map +1 -1
- package/publications/flags.js +1 -22
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +1 -90
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +1 -16
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +1 -16
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +1 -16
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +1 -42
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +1 -89
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +1 -50
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +1 -16
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +1 -16
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +1 -16
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +1 -682
- package/server-app.js.map +1 -1
- package/util/common.js +1 -498
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +1 -452
- package/util/schema-report-builder.js.map +1 -1
package/methods/collections.js
CHANGED
|
@@ -1,527 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadCollectionMethods = void 0;
|
|
4
|
-
var common_1 = require("../util/common");
|
|
5
|
-
var simpl_schema_1 = require("simpl-schema");
|
|
6
|
-
var pagination_model_1 = require("../models/pagination.model");
|
|
7
|
-
var index_1 = require("../index");
|
|
8
|
-
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
9
|
-
function loadCollectionMethods(methodManager) {
|
|
10
|
-
methodManager.methods({
|
|
11
|
-
collectionListAll: {
|
|
12
|
-
function: function () {
|
|
13
|
-
return new Promise(function (resolve, reject) {
|
|
14
|
-
resolve(index_1.ResolveIOServer.getMongoManager().collections().map(function (a) { return a.collectionName; }).sort(function (a, b) { return a.localeCompare(b); }));
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
collectionListRB: {
|
|
19
|
-
function: function () {
|
|
20
|
-
return new Promise(function (resolve, reject) {
|
|
21
|
-
resolve(index_1.ResolveIOServer.getMongoManager().collections().filter(function (a) { return a.useRB; }).map(function (a) { return a.collectionName; }).sort(function (a, b) { return a.localeCompare(b); }));
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
// Query database for any collection and query
|
|
26
|
-
findOne: {
|
|
27
|
-
check: new simpl_schema_1.default({
|
|
28
|
-
collection: {
|
|
29
|
-
type: String
|
|
30
|
-
},
|
|
31
|
-
query: {
|
|
32
|
-
type: Object,
|
|
33
|
-
blackbox: true
|
|
34
|
-
}
|
|
35
|
-
}),
|
|
36
|
-
function: function (collection, query) {
|
|
37
|
-
if (query === void 0) { query = {}; }
|
|
38
|
-
return new Promise(function (resolve, reject) {
|
|
39
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
40
|
-
reject('Invalid collection');
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).findOne(query).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
find: {
|
|
49
|
-
check: new simpl_schema_1.default({
|
|
50
|
-
collection: {
|
|
51
|
-
type: String
|
|
52
|
-
},
|
|
53
|
-
query: {
|
|
54
|
-
type: Object,
|
|
55
|
-
blackbox: true
|
|
56
|
-
},
|
|
57
|
-
sort: {
|
|
58
|
-
type: Object,
|
|
59
|
-
blackbox: true,
|
|
60
|
-
optional: true
|
|
61
|
-
}
|
|
62
|
-
}),
|
|
63
|
-
function: function (collection, query, sortQuery) {
|
|
64
|
-
if (query === void 0) { query = {}; }
|
|
65
|
-
if (sortQuery === void 0) { sortQuery = {}; }
|
|
66
|
-
return new Promise(function (resolve, reject) {
|
|
67
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
68
|
-
reject('Invalid collection');
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).find(query, { sort: sortQuery }).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
findWithOptions: {
|
|
77
|
-
check: new simpl_schema_1.default({
|
|
78
|
-
collection: {
|
|
79
|
-
type: String
|
|
80
|
-
},
|
|
81
|
-
query: {
|
|
82
|
-
type: Object,
|
|
83
|
-
blackbox: true
|
|
84
|
-
},
|
|
85
|
-
options: {
|
|
86
|
-
type: pagination_model_1.PaginationOptionsSchema
|
|
87
|
-
}
|
|
88
|
-
}),
|
|
89
|
-
function: function (collection, query, options) {
|
|
90
|
-
return new Promise(function (resolve, reject) {
|
|
91
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
92
|
-
reject('Invalid collection');
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
var optionsQuery = {};
|
|
96
|
-
if (options.fields && Object.keys(options.fields).length) {
|
|
97
|
-
optionsQuery['projection'] = options.fields;
|
|
98
|
-
}
|
|
99
|
-
if (options.sort && Object.keys(options.sort).length) {
|
|
100
|
-
optionsQuery['sort'] = options.sort;
|
|
101
|
-
}
|
|
102
|
-
if (options.limit) {
|
|
103
|
-
optionsQuery['limit'] = options.limit;
|
|
104
|
-
}
|
|
105
|
-
if (options.skip) {
|
|
106
|
-
optionsQuery['skip'] = options.skip;
|
|
107
|
-
}
|
|
108
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).find(query, optionsQuery).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
// Insert 1 document
|
|
114
|
-
// @Inputs: collection, document
|
|
115
|
-
// @Outputs: res = _id of new document, err = not inserted
|
|
116
|
-
insertDocument: {
|
|
117
|
-
check: new simpl_schema_1.default({
|
|
118
|
-
collection: {
|
|
119
|
-
type: String
|
|
120
|
-
},
|
|
121
|
-
document: {
|
|
122
|
-
type: Object,
|
|
123
|
-
blackbox: true
|
|
124
|
-
}
|
|
125
|
-
}),
|
|
126
|
-
function: function (collection, document) {
|
|
127
|
-
return new Promise(function (resolve, reject) {
|
|
128
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
129
|
-
reject('Invalid collection');
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
var id_1 = mongo_manager_1.objectIdHexString();
|
|
133
|
-
document['_id'] = id_1;
|
|
134
|
-
document['__v'] = 0;
|
|
135
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).insertOne(document).then(function () { return resolve(id_1); }, function (err) { return reject(err); });
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
// Insert 1 document
|
|
141
|
-
// @Inputs: collection, document
|
|
142
|
-
// @Outputs: res = _id of new document, err = not inserted
|
|
143
|
-
insertManyDocuments: {
|
|
144
|
-
check: new simpl_schema_1.default({
|
|
145
|
-
collection: {
|
|
146
|
-
type: String
|
|
147
|
-
},
|
|
148
|
-
documents: {
|
|
149
|
-
type: Array
|
|
150
|
-
},
|
|
151
|
-
'documents.$': {
|
|
152
|
-
type: Object,
|
|
153
|
-
blackbox: true
|
|
154
|
-
}
|
|
155
|
-
}),
|
|
156
|
-
function: function (collection, documents) {
|
|
157
|
-
return new Promise(function (resolve, reject) {
|
|
158
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
159
|
-
reject('Invalid collection');
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
documents.forEach(function (document) {
|
|
163
|
-
document['_id'] = mongo_manager_1.objectIdHexString();
|
|
164
|
-
document['__v'] = 0;
|
|
165
|
-
});
|
|
166
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).insertMany(documents).then(function () { return resolve(documents.map(function (a) { return a['_id']; })); }, function (err) { return reject(err); });
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
// Replaces 1 document with new document (from _id)
|
|
172
|
-
// @Inputs: collection, document id
|
|
173
|
-
// @Outputs: res = 1 (updated 1), err = not updated/wrong version
|
|
174
|
-
// Search for doc, check version, if found then try and update
|
|
175
|
-
updateDocument: {
|
|
176
|
-
check: new simpl_schema_1.default({
|
|
177
|
-
collection: {
|
|
178
|
-
type: String
|
|
179
|
-
},
|
|
180
|
-
f_document: {
|
|
181
|
-
type: Object,
|
|
182
|
-
blackbox: true
|
|
183
|
-
}
|
|
184
|
-
}),
|
|
185
|
-
function: function (collection, f_document) {
|
|
186
|
-
return new Promise(function (resolve, reject) {
|
|
187
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
188
|
-
reject('Invalid collection');
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: f_document['_id'] }, f_document).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
// Updates 1 document's props (from _id)
|
|
197
|
-
// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})
|
|
198
|
-
// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version
|
|
199
|
-
// Search for doc, check version, if found then try and update props
|
|
200
|
-
updateDocumentProps: {
|
|
201
|
-
check: new simpl_schema_1.default({
|
|
202
|
-
collection: {
|
|
203
|
-
type: String
|
|
204
|
-
},
|
|
205
|
-
doc_id: {
|
|
206
|
-
type: String
|
|
207
|
-
},
|
|
208
|
-
updateParams: {
|
|
209
|
-
type: Array
|
|
210
|
-
},
|
|
211
|
-
'updateParams.$': {
|
|
212
|
-
type: Object,
|
|
213
|
-
blackbox: true
|
|
214
|
-
},
|
|
215
|
-
doc__v: {
|
|
216
|
-
type: Number
|
|
217
|
-
}
|
|
218
|
-
}),
|
|
219
|
-
function: function (collection, doc_id, updateParams, doc__v) {
|
|
220
|
-
return new Promise(function (resolve, reject) {
|
|
221
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
222
|
-
reject('Invalid collection');
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: doc_id }).then(function (currDoc) {
|
|
226
|
-
if (currDoc) {
|
|
227
|
-
var modifiedDoc_1 = common_1.deepCopy(currDoc);
|
|
228
|
-
updateParams.forEach(function (data) {
|
|
229
|
-
modifiedDoc_1[data.prop] = data.data;
|
|
230
|
-
});
|
|
231
|
-
if (modifiedDoc_1.__v === doc__v) {
|
|
232
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: modifiedDoc_1._id }, modifiedDoc_1, {}, false, false, currDoc).then(function (res) {
|
|
233
|
-
resolve(res);
|
|
234
|
-
}, function (err) { return reject(err); });
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
console.log(new Date(), 'invalid version - ' + collection, currDoc.__v, doc__v);
|
|
238
|
-
if (index_1.ResolveIOServer.getMongoManager().collection(collection + '.versions')) {
|
|
239
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({
|
|
240
|
-
_id: {
|
|
241
|
-
_id: currDoc._id,
|
|
242
|
-
__v: doc__v
|
|
243
|
-
}
|
|
244
|
-
}).then(function (oldDoc) {
|
|
245
|
-
var newCurrDocId = currDoc._id;
|
|
246
|
-
var newCurrDocV = currDoc.__v;
|
|
247
|
-
if (oldDoc) {
|
|
248
|
-
var updatedDoc = common_1.getMongoMergeUpdatedDoc(modifiedDoc_1, currDoc, oldDoc);
|
|
249
|
-
updatedDoc._id = newCurrDocId;
|
|
250
|
-
updatedDoc.__v = newCurrDocV;
|
|
251
|
-
currDoc._id = newCurrDocId;
|
|
252
|
-
currDoc.__v = newCurrDocV;
|
|
253
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId }, updatedDoc, {}, false, false, currDoc).then(function (res) {
|
|
254
|
-
resolve(res);
|
|
255
|
-
}, function (err) { return reject(err); });
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
reject('Invalid Version And Could Not Find History Props - DB: ' + currDoc.__v + ', Trying to update with :' + doc__v);
|
|
259
|
-
}
|
|
260
|
-
}, function () { });
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
reject('Invalid Version And We Are NOT Using Versions On This Collection!');
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
reject('No Document');
|
|
269
|
-
}
|
|
270
|
-
}, function () { });
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
updateDocumentOffline: {
|
|
276
|
-
check: new simpl_schema_1.default({
|
|
277
|
-
collection: {
|
|
278
|
-
type: String
|
|
279
|
-
},
|
|
280
|
-
f_document: {
|
|
281
|
-
type: Object,
|
|
282
|
-
blackbox: true
|
|
283
|
-
},
|
|
284
|
-
f_oldDocument: {
|
|
285
|
-
type: Object,
|
|
286
|
-
blackbox: true
|
|
287
|
-
}
|
|
288
|
-
}),
|
|
289
|
-
function: function (collection, f_document, f_oldDocument) {
|
|
290
|
-
return new Promise(function (resolve, reject) {
|
|
291
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
292
|
-
reject('Invalid collection');
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: f_document['_id'] }).then(function (currDoc) {
|
|
296
|
-
if (currDoc) {
|
|
297
|
-
if (currDoc.__v === f_document['__v']) {
|
|
298
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: f_document['_id'] }, f_document, {}, false, false, currDoc).then(function (res) {
|
|
299
|
-
resolve(res);
|
|
300
|
-
}, function (err) { return reject(err); });
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
console.log('OFFLINE - invalid version - ' + collection, currDoc.__v, f_document['__v']);
|
|
304
|
-
var newCurrDocId_1 = currDoc._id;
|
|
305
|
-
var newCurrDocV_1 = currDoc.__v;
|
|
306
|
-
var oldDocV_1 = f_document['__v'];
|
|
307
|
-
if (f_oldDocument) {
|
|
308
|
-
var updatedDoc = common_1.getMongoMergeUpdatedDoc(f_document, currDoc, f_oldDocument);
|
|
309
|
-
updatedDoc._id = newCurrDocId_1;
|
|
310
|
-
updatedDoc.__v = newCurrDocV_1;
|
|
311
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId_1 }, updatedDoc, {}, false, false, currDoc).then(function (res) {
|
|
312
|
-
resolve(res);
|
|
313
|
-
}, function (err) { return reject(err); });
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
if (index_1.ResolveIOServer.getMongoManager().collection(collection + '.versions')) {
|
|
317
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({
|
|
318
|
-
_id: {
|
|
319
|
-
_id: newCurrDocId_1,
|
|
320
|
-
__v: oldDocV_1
|
|
321
|
-
}
|
|
322
|
-
}).then(function (oldDoc) {
|
|
323
|
-
if (oldDoc) {
|
|
324
|
-
var updatedDoc = common_1.getMongoMergeUpdatedDoc(f_document, currDoc, oldDoc);
|
|
325
|
-
updatedDoc._id = newCurrDocId_1;
|
|
326
|
-
updatedDoc.__v = newCurrDocV_1;
|
|
327
|
-
currDoc._id = newCurrDocId_1;
|
|
328
|
-
currDoc.__v = newCurrDocV_1;
|
|
329
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId_1 }, updatedDoc, {}, false, false, currDoc).then(function (res) {
|
|
330
|
-
resolve(res);
|
|
331
|
-
}, function (err) { return reject(err); });
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
reject('OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + currDoc.__v + ', Trying to update with :' + oldDocV_1);
|
|
335
|
-
}
|
|
336
|
-
}, function () { });
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
reject('Invalid Version And We Are NOT Using Versions On This Collection!');
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
reject('No Document');
|
|
346
|
-
}
|
|
347
|
-
}, function () { });
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
// Updates 1 document's props (from _id)
|
|
353
|
-
// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})
|
|
354
|
-
// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version
|
|
355
|
-
// Search for doc, check version, if found then try and update props
|
|
356
|
-
updateDocumentPropsOffline: {
|
|
357
|
-
check: new simpl_schema_1.default({
|
|
358
|
-
collection: {
|
|
359
|
-
type: String
|
|
360
|
-
},
|
|
361
|
-
doc_id: {
|
|
362
|
-
type: String
|
|
363
|
-
},
|
|
364
|
-
updateParams: {
|
|
365
|
-
type: Array
|
|
366
|
-
},
|
|
367
|
-
'updateParams.$': {
|
|
368
|
-
type: Object,
|
|
369
|
-
blackbox: true
|
|
370
|
-
},
|
|
371
|
-
doc__v: {
|
|
372
|
-
type: Number
|
|
373
|
-
},
|
|
374
|
-
f_oldDocument: {
|
|
375
|
-
type: Object,
|
|
376
|
-
blackbox: true
|
|
377
|
-
}
|
|
378
|
-
}),
|
|
379
|
-
function: function (collection, doc_id, updateParams, doc__v, f_oldDocument) {
|
|
380
|
-
return new Promise(function (resolve, reject) {
|
|
381
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
382
|
-
reject('Invalid collection');
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: doc_id }, null, true).then(function (currDoc) {
|
|
386
|
-
if (currDoc) {
|
|
387
|
-
var modifiedDoc_2 = common_1.deepCopy(currDoc);
|
|
388
|
-
updateParams.forEach(function (data) {
|
|
389
|
-
modifiedDoc_2[data.prop] = data.data;
|
|
390
|
-
});
|
|
391
|
-
if (modifiedDoc_2.__v === doc__v) {
|
|
392
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: modifiedDoc_2._id }, modifiedDoc_2, {}, false, false, currDoc).then(function (res) {
|
|
393
|
-
resolve(res);
|
|
394
|
-
}, function (err) { return reject(err); });
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
console.log('OFFLINE - invalid version - ' + collection, currDoc.__v, doc__v);
|
|
398
|
-
var newCurrDocId_2 = currDoc._id;
|
|
399
|
-
var newCurrDocV_2 = currDoc.__v;
|
|
400
|
-
if (f_oldDocument) {
|
|
401
|
-
var updatedDoc = common_1.getMongoMergeUpdatedDoc(modifiedDoc_2, currDoc, f_oldDocument);
|
|
402
|
-
updatedDoc._id = newCurrDocId_2;
|
|
403
|
-
updatedDoc.__v = currDoc.__v;
|
|
404
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId_2 }, updatedDoc, {}, false, false, currDoc).then(function (res) {
|
|
405
|
-
resolve(res);
|
|
406
|
-
}, function (err) { return reject(err); });
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
if (index_1.ResolveIOServer.getMongoManager().collection(collection + '.versions')) {
|
|
410
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({
|
|
411
|
-
_id: {
|
|
412
|
-
_id: currDoc._id,
|
|
413
|
-
__v: doc__v
|
|
414
|
-
}
|
|
415
|
-
}).then(function (oldDoc) {
|
|
416
|
-
if (oldDoc) {
|
|
417
|
-
var updatedDoc = common_1.getMongoMergeUpdatedDoc(modifiedDoc_2, currDoc, oldDoc);
|
|
418
|
-
updatedDoc._id = newCurrDocId_2;
|
|
419
|
-
updatedDoc.__v = newCurrDocV_2;
|
|
420
|
-
currDoc._id = newCurrDocId_2;
|
|
421
|
-
currDoc.__v = newCurrDocV_2;
|
|
422
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId_2 }, updatedDoc, {}, false, false, currDoc).then(function (res) {
|
|
423
|
-
resolve(res);
|
|
424
|
-
}, function (err) { return reject(err); });
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
reject('OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + currDoc.__v + ', Trying to update with :' + doc__v);
|
|
428
|
-
}
|
|
429
|
-
}, function () { });
|
|
430
|
-
}
|
|
431
|
-
else {
|
|
432
|
-
reject('Invalid Version And We Are NOT Using Versions On This Collection!');
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
else {
|
|
438
|
-
reject('No Document');
|
|
439
|
-
}
|
|
440
|
-
}, function () { });
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
},
|
|
445
|
-
// Removes 1 document (from _id)
|
|
446
|
-
// @Inputs: collection, document id
|
|
447
|
-
// @Outputs: res = 1 (deleted), res = 0 (not deleted), err = not deleted
|
|
448
|
-
// Search for doc, if found then try and remove
|
|
449
|
-
removeDocument: {
|
|
450
|
-
check: new simpl_schema_1.default({
|
|
451
|
-
collection: {
|
|
452
|
-
type: String
|
|
453
|
-
},
|
|
454
|
-
doc_id: {
|
|
455
|
-
type: String
|
|
456
|
-
}
|
|
457
|
-
}),
|
|
458
|
-
function: function (collection, doc_id) {
|
|
459
|
-
return new Promise(function (resolve, reject) {
|
|
460
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
461
|
-
reject('Invalid collection');
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).deleteOne({ _id: doc_id }).then(function (res) {
|
|
465
|
-
resolve(res);
|
|
466
|
-
}, function (err) {
|
|
467
|
-
reject(err);
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
},
|
|
473
|
-
removeDocumentWithQuery: {
|
|
474
|
-
check: new simpl_schema_1.default({
|
|
475
|
-
collection: {
|
|
476
|
-
type: String
|
|
477
|
-
},
|
|
478
|
-
query: {
|
|
479
|
-
type: Object,
|
|
480
|
-
blackbox: true
|
|
481
|
-
}
|
|
482
|
-
}),
|
|
483
|
-
function: function (collection, query) {
|
|
484
|
-
return new Promise(function (resolve, reject) {
|
|
485
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
486
|
-
reject('Invalid collection');
|
|
487
|
-
}
|
|
488
|
-
else {
|
|
489
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).deleteOne(query).then(function (res) {
|
|
490
|
-
resolve(res);
|
|
491
|
-
}, function (err) {
|
|
492
|
-
reject(err);
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
},
|
|
498
|
-
removeDocumentsWithQuery: {
|
|
499
|
-
check: new simpl_schema_1.default({
|
|
500
|
-
collection: {
|
|
501
|
-
type: String
|
|
502
|
-
},
|
|
503
|
-
query: {
|
|
504
|
-
type: Object,
|
|
505
|
-
blackbox: true
|
|
506
|
-
}
|
|
507
|
-
}),
|
|
508
|
-
function: function (collection, query) {
|
|
509
|
-
return new Promise(function (resolve, reject) {
|
|
510
|
-
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
511
|
-
reject('Invalid collection');
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
index_1.ResolveIOServer.getMongoManager().collection(collection).deleteMany(query).then(function (res) {
|
|
515
|
-
resolve(res);
|
|
516
|
-
}, function (err) {
|
|
517
|
-
reject(err);
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
exports.loadCollectionMethods = loadCollectionMethods;
|
|
526
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadCollectionMethods=void 0;var common_1=require("../util/common"),simpl_schema_1=require("simpl-schema"),pagination_model_1=require("../models/pagination.model"),index_1=require("../index"),mongo_manager_1=require("../managers/mongo.manager");function loadCollectionMethods(e){e.methods({collectionListAll:{function:function(){return new Promise((function(e,n){e(index_1.ResolveIOServer.getMongoManager().collections().map((function(e){return e.collectionName})).sort((function(e,n){return e.localeCompare(n)})))}))}},collectionListRB:{function:function(){return new Promise((function(e,n){e(index_1.ResolveIOServer.getMongoManager().collections().filter((function(e){return e.useRB})).map((function(e){return e.collectionName})).sort((function(e,n){return e.localeCompare(n)})))}))}},findOne:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,n){return void 0===n&&(n={}),new Promise((function(o,t){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).findOne(n).then((function(e){return o(e)}),(function(e){return t(e)})):t("Invalid collection")}))}},find:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0},sort:{type:Object,blackbox:!0,optional:!0}}),function:function(e,n,o){return void 0===n&&(n={}),void 0===o&&(o={}),new Promise((function(t,i){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).find(n,{sort:o}).then((function(e){return t(e)}),(function(e){return i(e)})):i("Invalid collection")}))}},findWithOptions:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0},options:{type:pagination_model_1.PaginationOptionsSchema}}),function:function(e,n,o){return new Promise((function(t,i){if(index_1.ResolveIOServer.getMongoManager().collection(e)){var c={};o.fields&&Object.keys(o.fields).length&&(c.projection=o.fields),o.sort&&Object.keys(o.sort).length&&(c.sort=o.sort),o.limit&&(c.limit=o.limit),o.skip&&(c.skip=o.skip),index_1.ResolveIOServer.getMongoManager().collection(e).find(n,c).then((function(e){return t(e)}),(function(e){return i(e)}))}else i("Invalid collection")}))}},insertDocument:{check:new simpl_schema_1.default({collection:{type:String},document:{type:Object,blackbox:!0}}),function:function(e,n){return new Promise((function(o,t){if(index_1.ResolveIOServer.getMongoManager().collection(e)){var i=mongo_manager_1.objectIdHexString();n._id=i,n.__v=0,index_1.ResolveIOServer.getMongoManager().collection(e).insertOne(n).then((function(){return o(i)}),(function(e){return t(e)}))}else t("Invalid collection")}))}},insertManyDocuments:{check:new simpl_schema_1.default({collection:{type:String},documents:{type:Array},"documents.$":{type:Object,blackbox:!0}}),function:function(e,n){return new Promise((function(o,t){index_1.ResolveIOServer.getMongoManager().collection(e)?(n.forEach((function(e){e._id=mongo_manager_1.objectIdHexString(),e.__v=0})),index_1.ResolveIOServer.getMongoManager().collection(e).insertMany(n).then((function(){return o(n.map((function(e){return e._id})))}),(function(e){return t(e)}))):t("Invalid collection")}))}},updateDocument:{check:new simpl_schema_1.default({collection:{type:String},f_document:{type:Object,blackbox:!0}}),function:function(e,n){return new Promise((function(o,t){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:n._id},n).then((function(e){return o(e)}),(function(e){return t(e)})):t("Invalid collection")}))}},updateDocumentProps:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String},updateParams:{type:Array},"updateParams.$":{type:Object,blackbox:!0},doc__v:{type:Number}}),function:function(e,n,o,t){return new Promise((function(i,c){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).findOne({_id:n}).then((function(n){if(n){var r=common_1.deepCopy(n);o.forEach((function(e){r[e.prop]=e.data})),r.__v===t?index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:r._id},r,{},!1,!1,n).then((function(e){i(e)}),(function(e){return c(e)})):(console.log(new Date,"invalid version - "+e,n.__v,t),index_1.ResolveIOServer.getMongoManager().collection(e+".versions")?index_1.ResolveIOServer.getMongoManager().collection(e+".versions").findOne({_id:{_id:n._id,__v:t}}).then((function(o){var l=n._id,a=n.__v;if(o){var d=common_1.getMongoMergeUpdatedDoc(r,n,o);d._id=l,d.__v=a,n._id=l,n.__v=a,index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:l},d,{},!1,!1,n).then((function(e){i(e)}),(function(e){return c(e)}))}else c("Invalid Version And Could Not Find History Props - DB: "+n.__v+", Trying to update with :"+t)}),(function(){})):c("Invalid Version And We Are NOT Using Versions On This Collection!"))}else c("No Document")}),(function(){})):c("Invalid collection")}))}},updateDocumentOffline:{check:new simpl_schema_1.default({collection:{type:String},f_document:{type:Object,blackbox:!0},f_oldDocument:{type:Object,blackbox:!0}}),function:function(e,n,o){return new Promise((function(t,i){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).findOne({_id:n._id}).then((function(c){if(c)if(c.__v===n.__v)index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:n._id},n,{},!1,!1,c).then((function(e){t(e)}),(function(e){return i(e)}));else{console.log("OFFLINE - invalid version - "+e,c.__v,n.__v);var r=c._id,l=c.__v,a=n.__v;if(o){var d=common_1.getMongoMergeUpdatedDoc(n,c,o);d._id=r,d.__v=l,index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:r},d,{},!1,!1,c).then((function(e){t(e)}),(function(e){return i(e)}))}else index_1.ResolveIOServer.getMongoManager().collection(e+".versions")?index_1.ResolveIOServer.getMongoManager().collection(e+".versions").findOne({_id:{_id:r,__v:a}}).then((function(o){if(o){var d=common_1.getMongoMergeUpdatedDoc(n,c,o);d._id=r,d.__v=l,c._id=r,c.__v=l,index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:r},d,{},!1,!1,c).then((function(e){t(e)}),(function(e){return i(e)}))}else i("OFFLINE - Invalid Version And Could Not Find History Props - DB: "+c.__v+", Trying to update with :"+a)}),(function(){})):i("Invalid Version And We Are NOT Using Versions On This Collection!")}else i("No Document")}),(function(){})):i("Invalid collection")}))}},updateDocumentPropsOffline:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String},updateParams:{type:Array},"updateParams.$":{type:Object,blackbox:!0},doc__v:{type:Number},f_oldDocument:{type:Object,blackbox:!0}}),function:function(e,n,o,t,i){return new Promise((function(c,r){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).findOne({_id:n},null,!0).then((function(n){if(n){var l=common_1.deepCopy(n);if(o.forEach((function(e){l[e.prop]=e.data})),l.__v===t)index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:l._id},l,{},!1,!1,n).then((function(e){c(e)}),(function(e){return r(e)}));else{console.log("OFFLINE - invalid version - "+e,n.__v,t);var a=n._id,d=n.__v;if(i){var u=common_1.getMongoMergeUpdatedDoc(l,n,i);u._id=a,u.__v=n.__v,index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:a},u,{},!1,!1,n).then((function(e){c(e)}),(function(e){return r(e)}))}else index_1.ResolveIOServer.getMongoManager().collection(e+".versions")?index_1.ResolveIOServer.getMongoManager().collection(e+".versions").findOne({_id:{_id:n._id,__v:t}}).then((function(o){if(o){var i=common_1.getMongoMergeUpdatedDoc(l,n,o);i._id=a,i.__v=d,n._id=a,n.__v=d,index_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:a},i,{},!1,!1,n).then((function(e){c(e)}),(function(e){return r(e)}))}else r("OFFLINE - Invalid Version And Could Not Find History Props - DB: "+n.__v+", Trying to update with :"+t)}),(function(){})):r("Invalid Version And We Are NOT Using Versions On This Collection!")}}else r("No Document")}),(function(){})):r("Invalid collection")}))}},removeDocument:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String}}),function:function(e,n){return new Promise((function(o,t){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).deleteOne({_id:n}).then((function(e){o(e)}),(function(e){t(e)})):t("Invalid collection")}))}},removeDocumentWithQuery:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,n){return new Promise((function(o,t){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).deleteOne(n).then((function(e){o(e)}),(function(e){t(e)})):t("Invalid collection")}))}},removeDocumentsWithQuery:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,n){return new Promise((function(o,t){index_1.ResolveIOServer.getMongoManager().collection(e)?index_1.ResolveIOServer.getMongoManager().collection(e).deleteMany(n).then((function(e){o(e)}),(function(e){t(e)})):t("Invalid collection")}))}}})}exports.loadCollectionMethods=loadCollectionMethods;
|
|
527
2
|
//# sourceMappingURL=collections.js.map
|