@steedos/objectql 2.7.27-beta.6 → 3.0.0-beta.7

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.
Files changed (142) hide show
  1. package/lib/actions/field_updates.js +3 -4
  2. package/lib/actions/field_updates.js.map +1 -1
  3. package/lib/actions/types/field_update_target.d.ts +1 -1
  4. package/lib/actions/types/workflow_notification.d.ts +1 -1
  5. package/lib/actions/types/workflow_outbound_message.d.ts +1 -1
  6. package/lib/actions/types/workflow_rule.d.ts +1 -1
  7. package/lib/actions/workflow_notifications.js +2 -3
  8. package/lib/actions/workflow_notifications.js.map +1 -1
  9. package/lib/actions/workflow_outbound_messages.js +2 -3
  10. package/lib/actions/workflow_outbound_messages.js.map +1 -1
  11. package/lib/actions/workflow_rule.d.ts +1 -1
  12. package/lib/actions/workflow_rule.js.map +1 -1
  13. package/lib/broker.js.map +1 -1
  14. package/lib/driver/driver.d.ts +2 -2
  15. package/lib/driver/field-encrytion/mongosharedconst.js +1 -2
  16. package/lib/driver/field-encrytion/mongosharedconst.js.map +1 -1
  17. package/lib/driver/fieldDBType.js +1 -1
  18. package/lib/driver/fieldDBType.js.map +1 -1
  19. package/lib/driver/format.js +1 -2
  20. package/lib/driver/format.js.map +1 -1
  21. package/lib/driver/metadata.d.ts +14 -36
  22. package/lib/driver/metadata.js +196 -171
  23. package/lib/driver/metadata.js.map +1 -1
  24. package/lib/driver/metadataOld.d.ts +40 -0
  25. package/lib/driver/metadataOld.js +222 -0
  26. package/lib/driver/metadataOld.js.map +1 -0
  27. package/lib/driver/meteorMongo.d.ts +2 -39
  28. package/lib/driver/meteorMongo.js +5 -758
  29. package/lib/driver/meteorMongo.js.map +1 -1
  30. package/lib/driver/mongo.d.ts +0 -1
  31. package/lib/driver/mongo.js +34 -33
  32. package/lib/driver/mongo.js.map +1 -1
  33. package/lib/driver/mysql.js.map +1 -1
  34. package/lib/driver/oracle.js.map +1 -1
  35. package/lib/driver/postgres.js.map +1 -1
  36. package/lib/driver/sqlite3.js.map +1 -1
  37. package/lib/driver/sqlserver.js.map +1 -1
  38. package/lib/errors/index.d.ts +1 -1
  39. package/lib/errors/index.js +7 -6
  40. package/lib/errors/index.js.map +1 -1
  41. package/lib/formula/core.d.ts +3 -1
  42. package/lib/formula/core.js +187 -119
  43. package/lib/formula/core.js.map +1 -1
  44. package/lib/formula/field_formula.js.map +1 -1
  45. package/lib/formula/index.d.ts +6 -6
  46. package/lib/formula/index.js +13 -5
  47. package/lib/formula/index.js.map +1 -1
  48. package/lib/formula/params.js +1 -2
  49. package/lib/formula/params.js.map +1 -1
  50. package/lib/formula/recompute.js.map +1 -1
  51. package/lib/formula/simple_params.js +1 -2
  52. package/lib/formula/simple_params.js.map +1 -1
  53. package/lib/formula/type.d.ts +7 -7
  54. package/lib/formula/type.js +1 -1
  55. package/lib/formula/type.js.map +1 -1
  56. package/lib/formula/util.js.map +1 -1
  57. package/lib/functions/function.js.map +1 -1
  58. package/lib/services/datasourceServiceFactory.js +26 -15
  59. package/lib/services/datasourceServiceFactory.js.map +1 -1
  60. package/lib/services/index.js +2 -3
  61. package/lib/services/index.js.map +1 -1
  62. package/lib/summary/core.js +53 -44
  63. package/lib/summary/core.js.map +1 -1
  64. package/lib/summary/field_summary.js.map +1 -1
  65. package/lib/summary/index.js.map +1 -1
  66. package/lib/summary/recompute.js.map +1 -1
  67. package/lib/summary/type.d.ts +1 -1
  68. package/lib/summary/type.js +2 -2
  69. package/lib/summary/type.js.map +1 -1
  70. package/lib/triggers/trigger.js.map +1 -1
  71. package/lib/ts-types/permissionset.d.ts +1 -1
  72. package/lib/ts-types/profile.d.ts +1 -1
  73. package/lib/ts-types/triggerActionParams.d.ts +1 -1
  74. package/lib/typeorm/driver.js.map +1 -1
  75. package/lib/typeorm/util.d.ts +1 -1
  76. package/lib/typeorm/util.js +5 -6
  77. package/lib/typeorm/util.js.map +1 -1
  78. package/lib/types/action.d.ts +1 -1
  79. package/lib/types/action.js.map +1 -1
  80. package/lib/types/app.d.ts +1 -1
  81. package/lib/types/app.js +9 -5
  82. package/lib/types/app.js.map +1 -1
  83. package/lib/types/connection.d.ts +2 -2
  84. package/lib/types/connection.js +11 -7
  85. package/lib/types/connection.js.map +1 -1
  86. package/lib/types/dashboard.d.ts +1 -1
  87. package/lib/types/dashboard.js +2 -2
  88. package/lib/types/dashboard.js.map +1 -1
  89. package/lib/types/datasource.d.ts +12 -7
  90. package/lib/types/datasource.js +146 -100
  91. package/lib/types/datasource.js.map +1 -1
  92. package/lib/types/defaultValue.js +1 -2
  93. package/lib/types/defaultValue.js.map +1 -1
  94. package/lib/types/field.js.map +1 -1
  95. package/lib/types/field_permission.js.map +1 -1
  96. package/lib/types/field_types.d.ts +1 -1
  97. package/lib/types/list_view.js.map +1 -1
  98. package/lib/types/listeners.d.ts +1 -1
  99. package/lib/types/method_base.js +2 -3
  100. package/lib/types/method_base.js.map +1 -1
  101. package/lib/types/object.d.ts +2 -1
  102. package/lib/types/object.js +715 -421
  103. package/lib/types/object.js.map +1 -1
  104. package/lib/types/object_events.js +1 -2
  105. package/lib/types/object_events.js.map +1 -1
  106. package/lib/types/object_layouts.js +4 -5
  107. package/lib/types/object_layouts.js.map +1 -1
  108. package/lib/types/object_permission.js.map +1 -1
  109. package/lib/types/query.d.ts +2 -2
  110. package/lib/types/report.d.ts +1 -1
  111. package/lib/types/report.js +2 -2
  112. package/lib/types/report.js.map +1 -1
  113. package/lib/types/restrictionRule.d.ts +1 -1
  114. package/lib/types/restrictionRule.js +81 -32
  115. package/lib/types/restrictionRule.js.map +1 -1
  116. package/lib/types/schema.d.ts +4 -5
  117. package/lib/types/schema.js +37 -55
  118. package/lib/types/schema.js.map +1 -1
  119. package/lib/types/shareRule.d.ts +1 -1
  120. package/lib/types/shareRule.js +87 -38
  121. package/lib/types/shareRule.js.map +1 -1
  122. package/lib/types/trigger.d.ts +2 -2
  123. package/lib/types/userSession.d.ts +5 -5
  124. package/lib/types/validation_rules.js +1 -2
  125. package/lib/types/validation_rules.js.map +1 -1
  126. package/lib/util/convert.js +2 -3
  127. package/lib/util/convert.js.map +1 -1
  128. package/lib/util/field.js.map +1 -1
  129. package/lib/util/function_expression.js.map +1 -1
  130. package/lib/util/index.d.ts +8 -9
  131. package/lib/util/index.js +127 -101
  132. package/lib/util/index.js.map +1 -1
  133. package/lib/util/locale.js.map +1 -1
  134. package/lib/util/permission_shares.js +1 -2
  135. package/lib/util/permission_shares.js.map +1 -1
  136. package/lib/util/suffix.js +0 -38
  137. package/lib/util/suffix.js.map +1 -1
  138. package/lib/util/transform.d.ts +2 -4
  139. package/lib/util/transform.js +11 -152
  140. package/lib/util/transform.js.map +1 -1
  141. package/lib/validators/index.js.map +1 -1
  142. package/package.json +14 -18
@@ -2,766 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SteedosMeteorMongoDriver = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var filters_1 = require("@steedos/filters");
6
- var odata_v4_mongodb_1 = require("@steedos/odata-v4-mongodb");
7
- var _ = require("underscore");
8
- var fieldDBType_1 = require("./fieldDBType");
9
- var mongodb_1 = require("mongodb");
10
- var format_1 = require("./format");
11
- var Fiber = require('fibers');
12
- var SteedosMeteorMongoDriver = (function () {
5
+ var index_1 = require("./index");
6
+ var SteedosMeteorMongoDriver = (function (_super) {
7
+ tslib_1.__extends(SteedosMeteorMongoDriver, _super);
13
8
  function SteedosMeteorMongoDriver(config) {
9
+ return _super.call(this, config) || this;
14
10
  }
15
- SteedosMeteorMongoDriver.prototype.getSupportedColumnTypes = function () {
16
- return [
17
- fieldDBType_1.SteedosFieldDBType.varchar,
18
- fieldDBType_1.SteedosFieldDBType.text,
19
- fieldDBType_1.SteedosFieldDBType.number,
20
- fieldDBType_1.SteedosFieldDBType.boolean,
21
- fieldDBType_1.SteedosFieldDBType.date,
22
- fieldDBType_1.SteedosFieldDBType.dateTime,
23
- fieldDBType_1.SteedosFieldDBType.json,
24
- fieldDBType_1.SteedosFieldDBType.array
25
- ];
26
- };
27
- SteedosMeteorMongoDriver.prototype.connect = function () {
28
- };
29
- SteedosMeteorMongoDriver.prototype.close = function () {
30
- };
31
- SteedosMeteorMongoDriver.prototype.init = function () {
32
- return tslib_1.__awaiter(this, void 0, void 0, function () {
33
- return tslib_1.__generator(this, function (_a) {
34
- return [2];
35
- });
36
- });
37
- };
38
- SteedosMeteorMongoDriver.prototype.directUpdateMany = function (tableName, queryFilters, data, userId) {
39
- return tslib_1.__awaiter(this, void 0, void 0, function () {
40
- var collection, mongoFilters;
41
- return tslib_1.__generator(this, function (_a) {
42
- switch (_a.label) {
43
- case 0:
44
- collection = this.collection(tableName);
45
- mongoFilters = this.getMongoFilters(queryFilters);
46
- return [4, new Promise(function (resolve, reject) {
47
- Fiber(function () {
48
- try {
49
- var invocation = new DDPCommon.MethodInvocation({
50
- isSimulation: true,
51
- userId: userId,
52
- connection: null,
53
- randomSeed: DDPCommon.makeRpcSeed()
54
- });
55
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
56
- return collection.direct.update(mongoFilters, { $set: data }, { multi: true, validate: false, filter: false });
57
- });
58
- resolve(result);
59
- }
60
- catch (error) {
61
- reject(error);
62
- }
63
- }).run();
64
- })];
65
- case 1: return [2, _a.sent()];
66
- }
67
- });
68
- });
69
- };
70
- SteedosMeteorMongoDriver.prototype.formatFiltersToMongoQuery = function (filters) {
71
- var emptyFilters = {};
72
- var odataQuery = "";
73
- if (_.isString(filters)) {
74
- odataQuery = filters;
75
- }
76
- else {
77
- odataQuery = (0, filters_1.formatFiltersToODataQuery)(filters);
78
- }
79
- if (!odataQuery) {
80
- return emptyFilters;
81
- }
82
- var query = (0, odata_v4_mongodb_1.createFilter)(odataQuery);
83
- return query;
84
- };
85
- SteedosMeteorMongoDriver.prototype.getMongoFilters = function (filters) {
86
- var emptyFilters = {};
87
- if (_.isUndefined(filters)) {
88
- return emptyFilters;
89
- }
90
- if (_.isString(filters) && !filters.length) {
91
- return emptyFilters;
92
- }
93
- if (_.isArray(filters) && !filters.length) {
94
- return emptyFilters;
95
- }
96
- var mongoFilters = this.formatFiltersToMongoQuery(filters);
97
- return mongoFilters;
98
- };
99
- SteedosMeteorMongoDriver.prototype.getMongoFieldsOptions = function (fields) {
100
- if (typeof fields == "string") {
101
- fields = fields.split(",").map(function (n) { return n.trim(); });
102
- }
103
- if (!(fields && fields.length)) {
104
- return {};
105
- }
106
- var projection = {};
107
- fields.forEach(function (field) {
108
- if (field) {
109
- projection[field] = 1;
110
- }
111
- });
112
- return projection;
113
- };
114
- SteedosMeteorMongoDriver.prototype.getMongoSortOptions = function (sort) {
115
- var result = undefined;
116
- if (sort && typeof sort === "string") {
117
- var arraySort = sort.split(",").map(function (n) { return n.trim(); });
118
- var stringSort_1 = "";
119
- arraySort.forEach(function (n) {
120
- if (n) {
121
- stringSort_1 += "".concat(n, ",");
122
- }
123
- });
124
- stringSort_1 = stringSort_1.replace(/,$/g, "");
125
- result = (0, odata_v4_mongodb_1.createQuery)("$orderby=".concat(stringSort_1)).sort;
126
- }
127
- return result;
128
- };
129
- SteedosMeteorMongoDriver.prototype.getMongoOptions = function (options) {
130
- if (_.isUndefined(options)) {
131
- return {};
132
- }
133
- var result = {};
134
- var projection = this.getMongoFieldsOptions(options.fields);
135
- var sort = this.getMongoSortOptions(options.sort);
136
- result.fields = projection;
137
- result.sort = sort;
138
- result.limit = options.top;
139
- result.skip = options.skip;
140
- return result;
141
- };
142
- SteedosMeteorMongoDriver.prototype.getAggregateOptions = function (options) {
143
- if (_.isUndefined(options)) {
144
- return [];
145
- }
146
- var result = [];
147
- var projection = this.getMongoFieldsOptions(options.fields);
148
- var sort = this.getMongoSortOptions(options.sort);
149
- if (!_.isEmpty(projection)) {
150
- result.push({ $project: projection });
151
- }
152
- if (!_.isEmpty(sort)) {
153
- result.push({ $sort: sort });
154
- }
155
- if (options.skip) {
156
- result.push({ $skip: options.skip });
157
- }
158
- if (options.top) {
159
- result.push({ $limit: options.top });
160
- }
161
- return result;
162
- };
163
- SteedosMeteorMongoDriver.prototype.getAggregateSortOption = function (options) {
164
- if (_.isUndefined(options)) {
165
- return;
166
- }
167
- var sort = this.getMongoSortOptions(options.sort);
168
- if (!_.isEmpty(sort)) {
169
- return { $sort: sort };
170
- }
171
- return;
172
- };
173
- SteedosMeteorMongoDriver.prototype.getAggregateProjectionOption = function (options) {
174
- if (_.isUndefined(options)) {
175
- return [];
176
- }
177
- var projection = this.getMongoFieldsOptions(options.fields);
178
- if (!_.isEmpty(projection)) {
179
- return { $project: projection };
180
- }
181
- return;
182
- };
183
- SteedosMeteorMongoDriver.prototype.getAggregateSkipLimitOptions = function (options) {
184
- if (_.isUndefined(options)) {
185
- return [];
186
- }
187
- var result = [];
188
- if (options.skip) {
189
- result.push({ $skip: options.skip });
190
- }
191
- if (options.top) {
192
- result.push({ $limit: options.top });
193
- }
194
- return result;
195
- };
196
- SteedosMeteorMongoDriver.prototype.collection = function (name) {
197
- return Creator.Collections[name];
198
- };
199
- ;
200
- SteedosMeteorMongoDriver.prototype.find = function (tableName, query, userId) {
201
- return tslib_1.__awaiter(this, void 0, void 0, function () {
202
- var collection, mongoFilters, mongoOptions;
203
- return tslib_1.__generator(this, function (_a) {
204
- switch (_a.label) {
205
- case 0:
206
- collection = this.collection(tableName);
207
- mongoFilters = this.getMongoFilters(query.filters);
208
- mongoOptions = this.getMongoOptions(query);
209
- return [4, new Promise(function (resolve, reject) {
210
- Fiber(function () {
211
- try {
212
- var invocation = new DDPCommon.MethodInvocation({
213
- isSimulation: true,
214
- userId: userId,
215
- connection: null,
216
- randomSeed: DDPCommon.makeRpcSeed()
217
- });
218
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
219
- return collection.find(mongoFilters, mongoOptions).fetch();
220
- });
221
- resolve(result);
222
- }
223
- catch (error) {
224
- reject(error);
225
- }
226
- }).run();
227
- })];
228
- case 1: return [2, _a.sent()];
229
- }
230
- });
231
- });
232
- };
233
- SteedosMeteorMongoDriver.prototype.aggregate = function (tableName, query, externalPipeline, userId) {
234
- return tslib_1.__awaiter(this, void 0, void 0, function () {
235
- var collection, rawCollection, pipeline, mongoFilters, sortOption, skipLimitOptions, projectionOption;
236
- return tslib_1.__generator(this, function (_a) {
237
- switch (_a.label) {
238
- case 0:
239
- collection = this.collection(tableName);
240
- rawCollection = collection.rawCollection();
241
- pipeline = [];
242
- mongoFilters = this.getMongoFilters(query.filters);
243
- sortOption = this.getAggregateSortOption(query);
244
- if (sortOption) {
245
- pipeline.push(sortOption);
246
- }
247
- pipeline.push({ $match: mongoFilters });
248
- skipLimitOptions = this.getAggregateSkipLimitOptions(query);
249
- if (!_.isEmpty(skipLimitOptions)) {
250
- pipeline = pipeline.concat(skipLimitOptions);
251
- }
252
- projectionOption = this.getAggregateProjectionOption(query);
253
- if (projectionOption) {
254
- pipeline.push(projectionOption);
255
- }
256
- if (!_.isEmpty(externalPipeline)) {
257
- pipeline = pipeline.concat(externalPipeline);
258
- }
259
- return [4, new Promise(function (resolve, reject) {
260
- Fiber(function () {
261
- try {
262
- rawCollection.aggregate(pipeline).toArray(function (err, data) {
263
- if (err) {
264
- reject(err);
265
- }
266
- resolve(data);
267
- });
268
- }
269
- catch (error) {
270
- reject(error);
271
- }
272
- }).run();
273
- })];
274
- case 1: return [2, _a.sent()];
275
- }
276
- });
277
- });
278
- };
279
- SteedosMeteorMongoDriver.prototype.directAggregate = function (tableName, query, externalPipeline, userId) {
280
- return tslib_1.__awaiter(this, void 0, void 0, function () {
281
- var collection, rawCollection, pipeline, mongoFilters, aggregateOptions;
282
- return tslib_1.__generator(this, function (_a) {
283
- switch (_a.label) {
284
- case 0:
285
- collection = this.collection(tableName);
286
- rawCollection = collection.rawCollection();
287
- pipeline = [];
288
- mongoFilters = this.getMongoFilters(query.filters);
289
- aggregateOptions = this.getAggregateOptions(query);
290
- pipeline.push({ $match: mongoFilters });
291
- pipeline = pipeline.concat(aggregateOptions).concat(externalPipeline);
292
- return [4, new Promise(function (resolve, reject) {
293
- Fiber(function () {
294
- try {
295
- rawCollection.aggregate(pipeline).toArray(function (err, data) {
296
- if (err) {
297
- reject(err);
298
- }
299
- resolve(data);
300
- });
301
- }
302
- catch (error) {
303
- reject(error);
304
- }
305
- }).run();
306
- })];
307
- case 1: return [2, _a.sent()];
308
- }
309
- });
310
- });
311
- };
312
- SteedosMeteorMongoDriver.prototype.directAggregatePrefixalPipeline = function (tableName, query, prefixalPipeline, userId) {
313
- return tslib_1.__awaiter(this, void 0, void 0, function () {
314
- var collection, rawCollection, pipeline, mongoFilters, aggregateOptions;
315
- return tslib_1.__generator(this, function (_a) {
316
- switch (_a.label) {
317
- case 0:
318
- collection = this.collection(tableName);
319
- rawCollection = collection.rawCollection();
320
- pipeline = [];
321
- mongoFilters = this.getMongoFilters(query.filters);
322
- aggregateOptions = this.getAggregateOptions(query);
323
- pipeline.push({ $match: mongoFilters });
324
- pipeline = prefixalPipeline.concat(pipeline).concat(aggregateOptions);
325
- return [4, new Promise(function (resolve, reject) {
326
- Fiber(function () {
327
- try {
328
- rawCollection.aggregate(pipeline).toArray(function (err, data) {
329
- if (err) {
330
- reject(err);
331
- }
332
- resolve(data);
333
- });
334
- }
335
- catch (error) {
336
- reject(error);
337
- }
338
- }).run();
339
- })];
340
- case 1: return [2, _a.sent()];
341
- }
342
- });
343
- });
344
- };
345
- SteedosMeteorMongoDriver.prototype.count = function (tableName, query, userId) {
346
- return tslib_1.__awaiter(this, void 0, void 0, function () {
347
- var collection, mongoFilters, mongoOptions;
348
- return tslib_1.__generator(this, function (_a) {
349
- switch (_a.label) {
350
- case 0:
351
- collection = this.collection(tableName);
352
- mongoFilters = this.getMongoFilters(query.filters);
353
- mongoOptions = this.getMongoOptions(query);
354
- return [4, new Promise(function (resolve, reject) {
355
- Fiber(function () {
356
- try {
357
- var invocation = new DDPCommon.MethodInvocation({
358
- isSimulation: true,
359
- userId: userId,
360
- connection: null,
361
- randomSeed: DDPCommon.makeRpcSeed()
362
- });
363
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
364
- return collection.find(mongoFilters, mongoOptions).count();
365
- });
366
- resolve(result);
367
- }
368
- catch (error) {
369
- reject(error);
370
- }
371
- }).run();
372
- })];
373
- case 1: return [2, _a.sent()];
374
- }
375
- });
376
- });
377
- };
378
- SteedosMeteorMongoDriver.prototype.findOne = function (tableName, id, query, userId) {
379
- return tslib_1.__awaiter(this, void 0, void 0, function () {
380
- var collection, mongoFilters, mongoOptions, self;
381
- return tslib_1.__generator(this, function (_a) {
382
- switch (_a.label) {
383
- case 0:
384
- collection = this.collection(tableName);
385
- mongoFilters = this.getMongoFilters(query.filters);
386
- mongoOptions = this.getMongoOptions(query);
387
- self = this;
388
- return [4, new Promise(function (resolve, reject) {
389
- Fiber(function () {
390
- try {
391
- var invocation = new DDPCommon.MethodInvocation({
392
- isSimulation: true,
393
- userId: userId,
394
- connection: null,
395
- randomSeed: DDPCommon.makeRpcSeed()
396
- });
397
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
398
- var selector = { _id: id };
399
- if (_.isObject(id)) {
400
- selector = self.getMongoFilters(id['filters']);
401
- }
402
- if (!_.isEmpty(mongoFilters)) {
403
- selector = Object.assign(mongoFilters, selector);
404
- }
405
- return collection.findOne(selector, mongoOptions);
406
- });
407
- resolve(result);
408
- }
409
- catch (error) {
410
- reject(error);
411
- }
412
- }).run();
413
- })];
414
- case 1: return [2, _a.sent()];
415
- }
416
- });
417
- });
418
- };
419
- SteedosMeteorMongoDriver.prototype.insert = function (tableName, data, userId) {
420
- return tslib_1.__awaiter(this, void 0, void 0, function () {
421
- var collection;
422
- return tslib_1.__generator(this, function (_a) {
423
- switch (_a.label) {
424
- case 0:
425
- collection = this.collection(tableName);
426
- return [4, new Promise(function (resolve, reject) {
427
- Fiber(function () {
428
- try {
429
- data._id = data._id || collection._makeNewID();
430
- var invocation = new DDPCommon.MethodInvocation({
431
- isSimulation: true,
432
- userId: userId,
433
- connection: null,
434
- randomSeed: DDPCommon.makeRpcSeed()
435
- });
436
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
437
- var recordId = collection.insert(data, { validate: false, filter: false });
438
- return collection.findOne({ _id: recordId });
439
- });
440
- resolve(result);
441
- }
442
- catch (error) {
443
- reject(error);
444
- }
445
- }).run();
446
- })];
447
- case 1: return [2, _a.sent()];
448
- }
449
- });
450
- });
451
- };
452
- SteedosMeteorMongoDriver.prototype.update = function (tableName, id, data, userId) {
453
- return tslib_1.__awaiter(this, void 0, void 0, function () {
454
- var collection, selector;
455
- return tslib_1.__generator(this, function (_a) {
456
- switch (_a.label) {
457
- case 0:
458
- collection = this.collection(tableName);
459
- if (_.isObject(id)) {
460
- selector = this.getMongoFilters(id['filters']);
461
- }
462
- else {
463
- selector = { _id: id };
464
- }
465
- return [4, new Promise(function (resolve, reject) {
466
- Fiber(function () {
467
- try {
468
- var invocation = new DDPCommon.MethodInvocation({
469
- isSimulation: true,
470
- userId: userId,
471
- connection: null,
472
- randomSeed: DDPCommon.makeRpcSeed()
473
- });
474
- var options_1 = { $set: {} };
475
- var keys = _.keys(data);
476
- _.each(keys, function (key) {
477
- if (_.include(['$inc', '$min', '$max', '$mul', '$push', '$addToSet', '$pop', '$pull', '$pullAll'], key)) {
478
- options_1[key] = data[key];
479
- }
480
- else {
481
- options_1.$set[key] = data[key];
482
- }
483
- });
484
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
485
- collection.update(selector, options_1, { validate: false, filter: false });
486
- return collection.findOne(selector);
487
- });
488
- resolve(result);
489
- }
490
- catch (error) {
491
- reject(error);
492
- }
493
- }).run();
494
- })];
495
- case 1: return [2, _a.sent()];
496
- }
497
- });
498
- });
499
- };
500
- SteedosMeteorMongoDriver.prototype.updateOne = function (tableName, id, data, userId) {
501
- return tslib_1.__awaiter(this, void 0, void 0, function () {
502
- var collection, selector;
503
- return tslib_1.__generator(this, function (_a) {
504
- switch (_a.label) {
505
- case 0:
506
- collection = this.collection(tableName);
507
- if (_.isObject(id)) {
508
- selector = this.getMongoFilters(id['filters']);
509
- }
510
- else {
511
- selector = { _id: id };
512
- }
513
- return [4, new Promise(function (resolve, reject) {
514
- Fiber(function () {
515
- try {
516
- var invocation = new DDPCommon.MethodInvocation({
517
- isSimulation: true,
518
- userId: userId,
519
- connection: null,
520
- randomSeed: DDPCommon.makeRpcSeed()
521
- });
522
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
523
- collection.update(selector, { $set: data }, { validate: false, filter: false });
524
- return collection.findOne(selector);
525
- });
526
- resolve(result);
527
- }
528
- catch (error) {
529
- reject(error);
530
- }
531
- }).run();
532
- })];
533
- case 1: return [2, _a.sent()];
534
- }
535
- });
536
- });
537
- };
538
- SteedosMeteorMongoDriver.prototype.updateMany = function (tableName, queryFilters, data, userId) {
539
- return tslib_1.__awaiter(this, void 0, void 0, function () {
540
- var collection, mongoFilters;
541
- return tslib_1.__generator(this, function (_a) {
542
- switch (_a.label) {
543
- case 0:
544
- collection = this.collection(tableName);
545
- mongoFilters = this.getMongoFilters(queryFilters);
546
- return [4, new Promise(function (resolve, reject) {
547
- Fiber(function () {
548
- try {
549
- var invocation = new DDPCommon.MethodInvocation({
550
- isSimulation: true,
551
- userId: userId,
552
- connection: null,
553
- randomSeed: DDPCommon.makeRpcSeed()
554
- });
555
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
556
- return collection.update(mongoFilters, { $set: data }, { multi: true, validate: false, filter: false });
557
- });
558
- resolve(result);
559
- }
560
- catch (error) {
561
- reject(error);
562
- }
563
- }).run();
564
- })];
565
- case 1: return [2, _a.sent()];
566
- }
567
- });
568
- });
569
- };
570
- SteedosMeteorMongoDriver.prototype.delete = function (tableName, id, userId) {
571
- return tslib_1.__awaiter(this, void 0, void 0, function () {
572
- var collection, selector;
573
- return tslib_1.__generator(this, function (_a) {
574
- switch (_a.label) {
575
- case 0:
576
- collection = this.collection(tableName);
577
- if (_.isObject(id)) {
578
- selector = this.getMongoFilters(id['filters']);
579
- }
580
- else {
581
- selector = { _id: id };
582
- }
583
- return [4, new Promise(function (resolve, reject) {
584
- Fiber(function () {
585
- try {
586
- var invocation = new DDPCommon.MethodInvocation({
587
- isSimulation: true,
588
- userId: userId,
589
- connection: null,
590
- randomSeed: DDPCommon.makeRpcSeed()
591
- });
592
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
593
- return collection.remove(selector);
594
- });
595
- resolve(result);
596
- }
597
- catch (error) {
598
- reject(error);
599
- }
600
- }).run();
601
- })];
602
- case 1: return [2, _a.sent()];
603
- }
604
- });
605
- });
606
- };
607
- SteedosMeteorMongoDriver.prototype.directFind = function (tableName, query, userId) {
608
- return tslib_1.__awaiter(this, void 0, void 0, function () {
609
- var collection, mongoFilters, mongoOptions;
610
- return tslib_1.__generator(this, function (_a) {
611
- switch (_a.label) {
612
- case 0:
613
- collection = this.collection(tableName);
614
- mongoFilters = this.getMongoFilters(query.filters);
615
- mongoOptions = this.getMongoOptions(query);
616
- return [4, new Promise(function (resolve, reject) {
617
- Fiber(function () {
618
- try {
619
- var invocation = new DDPCommon.MethodInvocation({
620
- isSimulation: true,
621
- userId: userId,
622
- connection: null,
623
- randomSeed: DDPCommon.makeRpcSeed()
624
- });
625
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
626
- return collection.direct.find(mongoFilters, mongoOptions).fetch();
627
- });
628
- resolve(result);
629
- }
630
- catch (error) {
631
- reject(error);
632
- }
633
- }).run();
634
- })];
635
- case 1: return [2, _a.sent()];
636
- }
637
- });
638
- });
639
- };
640
- SteedosMeteorMongoDriver.prototype.directUpdate = function (tableName, id, data, userId) {
641
- return tslib_1.__awaiter(this, void 0, void 0, function () {
642
- var collection, selector;
643
- return tslib_1.__generator(this, function (_a) {
644
- switch (_a.label) {
645
- case 0:
646
- collection = this.collection(tableName);
647
- if (_.isObject(id)) {
648
- selector = this.getMongoFilters(id['filters']);
649
- }
650
- else {
651
- selector = { _id: id };
652
- }
653
- return [4, new Promise(function (resolve, reject) {
654
- Fiber(function () {
655
- try {
656
- var invocation = new DDPCommon.MethodInvocation({
657
- isSimulation: true,
658
- userId: userId,
659
- connection: null,
660
- randomSeed: DDPCommon.makeRpcSeed()
661
- });
662
- var options_2 = { $set: {} };
663
- var keys = _.keys(data);
664
- _.each(keys, function (key) {
665
- if (_.include(['$inc', '$min', '$max', '$mul'], key)) {
666
- options_2[key] = data[key];
667
- }
668
- else {
669
- options_2.$set[key] = data[key];
670
- }
671
- });
672
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
673
- collection.direct.update(selector, options_2);
674
- return collection.findOne(selector);
675
- });
676
- resolve(result);
677
- }
678
- catch (error) {
679
- reject(error);
680
- }
681
- }).run();
682
- })];
683
- case 1: return [2, _a.sent()];
684
- }
685
- });
686
- });
687
- };
688
- SteedosMeteorMongoDriver.prototype.directInsert = function (tableName, data, userId) {
689
- return tslib_1.__awaiter(this, void 0, void 0, function () {
690
- var collection;
691
- return tslib_1.__generator(this, function (_a) {
692
- switch (_a.label) {
693
- case 0:
694
- collection = this.collection(tableName);
695
- return [4, new Promise(function (resolve, reject) {
696
- Fiber(function () {
697
- try {
698
- data._id = data._id || collection._makeNewID();
699
- var invocation = new DDPCommon.MethodInvocation({
700
- isSimulation: true,
701
- userId: userId,
702
- connection: null,
703
- randomSeed: DDPCommon.makeRpcSeed()
704
- });
705
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
706
- var recordId = collection.direct.insert(data);
707
- return collection.findOne({ _id: recordId });
708
- });
709
- resolve(result);
710
- }
711
- catch (error) {
712
- reject(error);
713
- }
714
- }).run();
715
- })];
716
- case 1: return [2, _a.sent()];
717
- }
718
- });
719
- });
720
- };
721
- SteedosMeteorMongoDriver.prototype.directDelete = function (tableName, id, userId) {
722
- return tslib_1.__awaiter(this, void 0, void 0, function () {
723
- var collection, selector;
724
- return tslib_1.__generator(this, function (_a) {
725
- switch (_a.label) {
726
- case 0:
727
- collection = this.collection(tableName);
728
- if (_.isObject(id)) {
729
- selector = this.getMongoFilters(id['filters']);
730
- }
731
- else {
732
- selector = { _id: id };
733
- }
734
- return [4, new Promise(function (resolve, reject) {
735
- Fiber(function () {
736
- try {
737
- var invocation = new DDPCommon.MethodInvocation({
738
- isSimulation: true,
739
- userId: userId,
740
- connection: null,
741
- randomSeed: DDPCommon.makeRpcSeed()
742
- });
743
- var result = DDP._CurrentInvocation.withValue(invocation, function () {
744
- return collection.direct.remove(selector);
745
- });
746
- resolve(result);
747
- }
748
- catch (error) {
749
- reject(error);
750
- }
751
- }).run();
752
- })];
753
- case 1: return [2, _a.sent()];
754
- }
755
- });
756
- });
757
- };
758
- SteedosMeteorMongoDriver.prototype._makeNewID = function (tableName) {
759
- return new mongodb_1.ObjectId().toHexString();
760
- };
761
- SteedosMeteorMongoDriver.prototype.formatRecord = function (doc, objectConfig) {
762
- return (0, format_1.formatRecord)(doc, objectConfig);
763
- };
764
11
  return SteedosMeteorMongoDriver;
765
- }());
12
+ }(index_1.SteedosMongoDriver));
766
13
  exports.SteedosMeteorMongoDriver = SteedosMeteorMongoDriver;
767
14
  //# sourceMappingURL=meteorMongo.js.map