remult 0.22.7-exp.0 → 0.22.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.
- package/SseSubscriptionServer.d.ts +25 -25
- package/SseSubscriptionServer.js +145 -145
- package/ably.d.ts +13 -13
- package/ably.js +59 -59
- package/assign.d.ts +1 -1
- package/assign.js +9 -9
- package/classType.d.ts +3 -3
- package/classType.js +2 -2
- package/esm/SseSubscriptionServer.d.ts +25 -25
- package/esm/SseSubscriptionServer.js +107 -104
- package/esm/ably.d.ts +13 -13
- package/esm/ably.js +30 -28
- package/esm/assign.d.ts +1 -1
- package/esm/assign.js +5 -5
- package/esm/classType.d.ts +3 -3
- package/esm/classType.js +1 -1
- package/esm/graphql.d.ts +14 -14
- package/esm/graphql.js +785 -785
- package/esm/index.d.ts +31 -31
- package/esm/index.js +25 -25
- package/esm/inputTypes.d.ts +9 -9
- package/esm/inputTypes.js +9 -9
- package/esm/live-query/data-provider-live-query-storage.d.ts +23 -23
- package/esm/live-query/data-provider-live-query-storage.js +91 -93
- package/esm/myLog.d.ts +1 -1
- package/esm/myLog.js +5 -5
- package/esm/postgres/index.d.ts +2 -2
- package/esm/postgres/index.js +2 -2
- package/esm/postgres/postgres-data-provider.d.ts +36 -36
- package/esm/postgres/postgres-data-provider.js +126 -122
- package/esm/postgres/schema-builder.d.ts +19 -19
- package/esm/postgres/schema-builder.js +197 -196
- package/esm/remult-express.d.ts +9 -9
- package/esm/remult-express.js +26 -25
- package/esm/remult-fastify.d.ts +6 -6
- package/esm/remult-fastify.js +68 -68
- package/esm/remult-fresh.d.ts +17 -17
- package/esm/remult-fresh.js +26 -26
- package/esm/remult-knex/index.d.ts +30 -30
- package/esm/remult-knex/index.js +466 -460
- package/esm/remult-mongo.d.ts +24 -24
- package/esm/remult-mongo.js +269 -262
- package/esm/remult-next.d.ts +25 -25
- package/esm/remult-next.js +114 -114
- package/esm/remult-sveltekit.d.ts +4 -4
- package/esm/remult-sveltekit.js +71 -71
- package/esm/server/JsonEntityFileStorage.d.ts +11 -11
- package/esm/server/JsonEntityFileStorage.js +27 -26
- package/esm/server/core.d.ts +4 -4
- package/esm/server/core.js +4 -4
- package/esm/server/expressBridge.d.ts +128 -128
- package/esm/server/expressBridge.js +988 -971
- package/esm/server/index.d.ts +6 -6
- package/esm/server/index.js +12 -12
- package/esm/server/initAsyncHooks.d.ts +1 -1
- package/esm/server/initAsyncHooks.js +9 -9
- package/esm/server/initDataProvider.d.ts +2 -2
- package/esm/server/initDataProvider.js +14 -14
- package/esm/src/CompoundIdField.d.ts +27 -27
- package/esm/src/CompoundIdField.js +54 -41
- package/esm/src/__EntityValueProvider.d.ts +11 -11
- package/esm/src/__EntityValueProvider.js +1 -1
- package/esm/src/__RowsOfDataForTesting.d.ts +3 -3
- package/esm/src/__RowsOfDataForTesting.js +1 -1
- package/esm/src/buildRestDataProvider.d.ts +31 -31
- package/esm/src/buildRestDataProvider.js +121 -120
- package/esm/src/column-interfaces.d.ts +160 -160
- package/esm/src/column-interfaces.js +7 -7
- package/esm/src/column.d.ts +31 -31
- package/esm/src/column.js +108 -101
- package/esm/src/context.d.ts +134 -134
- package/esm/src/context.js +287 -282
- package/esm/src/data-api.d.ts +38 -38
- package/esm/src/data-api.js +281 -279
- package/esm/src/data-interfaces.d.ts +41 -41
- package/esm/src/data-interfaces.js +12 -12
- package/esm/src/data-providers/array-entity-data-provider.d.ts +22 -22
- package/esm/src/data-providers/array-entity-data-provider.js +252 -249
- package/esm/src/data-providers/in-memory-database.d.ts +9 -9
- package/esm/src/data-providers/in-memory-database.js +16 -18
- package/esm/src/data-providers/json-data-provider.d.ts +12 -12
- package/esm/src/data-providers/json-data-provider.js +55 -52
- package/esm/src/data-providers/rest-data-provider.d.ts +39 -39
- package/esm/src/data-providers/rest-data-provider.js +272 -267
- package/esm/src/data-providers/sql-database.d.ts +33 -33
- package/esm/src/data-providers/sql-database.js +401 -394
- package/esm/src/data-providers/web-sql-data-provider.d.ts +21 -21
- package/esm/src/data-providers/web-sql-data-provider.js +145 -137
- package/esm/src/entity.d.ts +95 -95
- package/esm/src/entity.js +1 -1
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -50
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +165 -162
- package/esm/src/filter/filter-interfaces.d.ts +86 -86
- package/esm/src/filter/filter-interfaces.js +524 -515
- package/esm/src/live-query/LiveQueryClient.d.ts +1 -1
- package/esm/src/live-query/LiveQueryClient.js +196 -192
- package/esm/src/live-query/SseSubscriptionClient.d.ts +5 -5
- package/esm/src/live-query/SseSubscriptionClient.js +86 -86
- package/esm/src/live-query/SubscriptionChannel.d.ts +41 -41
- package/esm/src/live-query/SubscriptionChannel.js +126 -121
- package/esm/src/live-query/SubscriptionServer.d.ts +38 -38
- package/esm/src/live-query/SubscriptionServer.js +114 -112
- package/esm/src/remult-proxy.d.ts +2 -2
- package/esm/src/remult-proxy.js +177 -178
- package/esm/src/remult3/DecoratorReplacer.d.ts +10 -10
- package/esm/src/remult3/DecoratorReplacer.js +20 -20
- package/esm/src/remult3/RepositoryImplementation.d.ts +332 -332
- package/esm/src/remult3/RepositoryImplementation.js +2122 -2051
- package/esm/src/remult3/__updateEntityBasedOnWhere.d.ts +2 -2
- package/esm/src/remult3/__updateEntityBasedOnWhere.js +24 -24
- package/esm/src/remult3/entity.d.ts +28 -28
- package/esm/src/remult3/entity.js +70 -70
- package/esm/src/remult3/getEntityRef.d.ts +9 -9
- package/esm/src/remult3/getEntityRef.js +27 -27
- package/esm/src/remult3/remult3.d.ts +397 -397
- package/esm/src/remult3/remult3.js +1 -1
- package/esm/src/resultCompoundIdFilter.d.ts +3 -3
- package/esm/src/resultCompoundIdFilter.js +16 -16
- package/esm/src/server-action-info.d.ts +10 -10
- package/esm/src/server-action-info.js +12 -12
- package/esm/src/server-action.d.ts +79 -79
- package/esm/src/server-action.js +397 -387
- package/esm/src/sort.d.ts +16 -16
- package/esm/src/sort.js +105 -104
- package/esm/src/sql-command.d.ts +19 -19
- package/esm/src/sql-command.js +1 -1
- package/esm/src/validators.d.ts +14 -14
- package/esm/src/validators.js +36 -36
- package/esm/src/valueConverters.d.ts +13 -13
- package/esm/src/valueConverters.js +210 -210
- package/esm/urlBuilder.d.ts +6 -6
- package/esm/urlBuilder.js +20 -19
- package/graphql.d.ts +14 -14
- package/graphql.js +953 -953
- package/index.d.ts +31 -31
- package/index.js +67 -67
- package/inputTypes.d.ts +9 -9
- package/inputTypes.js +16 -16
- package/live-query/data-provider-live-query-storage.d.ts +23 -23
- package/live-query/data-provider-live-query-storage.js +263 -263
- package/myLog.d.ts +1 -1
- package/myLog.js +20 -20
- package/package.json +1 -1
- package/postgres/index.d.ts +2 -2
- package/postgres/index.js +5 -5
- package/postgres/postgres-data-provider.d.ts +36 -36
- package/postgres/postgres-data-provider.js +191 -191
- package/postgres/schema-builder.d.ts +19 -19
- package/postgres/schema-builder.js +369 -369
- package/remult-express.d.ts +9 -9
- package/remult-express.js +34 -33
- package/remult-fastify.d.ts +6 -6
- package/remult-fastify.js +79 -79
- package/remult-fresh.d.ts +17 -17
- package/remult-fresh.js +41 -41
- package/remult-knex/index.d.ts +30 -30
- package/remult-knex/index.js +917 -915
- package/remult-mongo.d.ts +24 -24
- package/remult-mongo.js +515 -515
- package/remult-next.d.ts +25 -25
- package/remult-next.js +171 -171
- package/remult-sveltekit.d.ts +4 -4
- package/remult-sveltekit.js +110 -110
- package/server/JsonEntityFileStorage.d.ts +11 -11
- package/server/JsonEntityFileStorage.js +35 -35
- package/server/core.d.ts +4 -4
- package/server/core.js +12 -12
- package/server/expressBridge.d.ts +128 -128
- package/server/expressBridge.js +1401 -1402
- package/server/index.d.ts +6 -6
- package/server/index.js +24 -24
- package/server/initAsyncHooks.d.ts +1 -1
- package/server/initAsyncHooks.js +13 -13
- package/server/initDataProvider.d.ts +2 -2
- package/server/initDataProvider.js +26 -26
- package/src/CompoundIdField.d.ts +27 -27
- package/src/CompoundIdField.js +54 -54
- package/src/__EntityValueProvider.d.ts +11 -11
- package/src/__EntityValueProvider.js +2 -2
- package/src/__RowsOfDataForTesting.d.ts +3 -3
- package/src/__RowsOfDataForTesting.js +2 -2
- package/src/buildRestDataProvider.d.ts +31 -31
- package/src/buildRestDataProvider.js +177 -174
- package/src/column-interfaces.d.ts +160 -160
- package/src/column-interfaces.js +11 -11
- package/src/column.d.ts +31 -31
- package/src/column.js +132 -132
- package/src/context.d.ts +134 -134
- package/src/context.js +451 -451
- package/src/data-api.d.ts +38 -38
- package/src/data-api.js +524 -524
- package/src/data-interfaces.d.ts +41 -41
- package/src/data-interfaces.js +16 -16
- package/src/data-providers/array-entity-data-provider.d.ts +22 -22
- package/src/data-providers/array-entity-data-provider.js +364 -364
- package/src/data-providers/in-memory-database.d.ts +9 -9
- package/src/data-providers/in-memory-database.js +33 -33
- package/src/data-providers/json-data-provider.d.ts +12 -12
- package/src/data-providers/json-data-provider.js +106 -106
- package/src/data-providers/rest-data-provider.d.ts +39 -39
- package/src/data-providers/rest-data-provider.js +388 -388
- package/src/data-providers/sql-database.d.ts +33 -33
- package/src/data-providers/sql-database.js +653 -653
- package/src/data-providers/web-sql-data-provider.d.ts +21 -21
- package/src/data-providers/web-sql-data-provider.js +229 -229
- package/src/entity.d.ts +95 -95
- package/src/entity.js +2 -2
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -50
- package/src/filter/filter-consumer-bridge-to-sql-request.js +307 -307
- package/src/filter/filter-interfaces.d.ts +86 -86
- package/src/filter/filter-interfaces.js +693 -685
- package/src/live-query/LiveQueryClient.d.ts +1 -1
- package/src/live-query/LiveQueryClient.js +293 -293
- package/src/live-query/SseSubscriptionClient.d.ts +5 -5
- package/src/live-query/SseSubscriptionClient.js +154 -154
- package/src/live-query/SubscriptionChannel.d.ts +41 -41
- package/src/live-query/SubscriptionChannel.js +189 -189
- package/src/live-query/SubscriptionServer.d.ts +38 -38
- package/src/live-query/SubscriptionServer.js +264 -264
- package/src/remult-proxy.d.ts +2 -2
- package/src/remult-proxy.js +307 -307
- package/src/remult3/DecoratorReplacer.d.ts +10 -10
- package/src/remult3/DecoratorReplacer.js +24 -24
- package/src/remult3/RepositoryImplementation.d.ts +332 -332
- package/src/remult3/RepositoryImplementation.js +3391 -3373
- package/src/remult3/__updateEntityBasedOnWhere.d.ts +2 -2
- package/src/remult3/__updateEntityBasedOnWhere.js +28 -28
- package/src/remult3/entity.d.ts +28 -28
- package/src/remult3/entity.js +88 -88
- package/src/remult3/getEntityRef.d.ts +9 -9
- package/src/remult3/getEntityRef.js +35 -35
- package/src/remult3/remult3.d.ts +397 -397
- package/src/remult3/remult3.js +2 -2
- package/src/resultCompoundIdFilter.d.ts +3 -3
- package/src/resultCompoundIdFilter.js +20 -20
- package/src/server-action-info.d.ts +10 -10
- package/src/server-action-info.js +15 -15
- package/src/server-action.d.ts +79 -79
- package/src/server-action.js +632 -632
- package/src/sort.d.ts +16 -16
- package/src/sort.js +161 -161
- package/src/sql-command.d.ts +19 -19
- package/src/sql-command.js +2 -2
- package/src/validators.d.ts +14 -14
- package/src/validators.js +71 -69
- package/src/valueConverters.d.ts +13 -13
- package/src/valueConverters.js +213 -213
- package/urlBuilder.d.ts +6 -6
- package/urlBuilder.js +25 -25
package/remult-mongo.js
CHANGED
|
@@ -1,515 +1,515 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongoDataProvider = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var _1 = require(".");
|
|
6
|
-
var filter_consumer_bridge_to_sql_request_1 = require("./src/filter/filter-consumer-bridge-to-sql-request");
|
|
7
|
-
var remult_proxy_1 = require("./src/remult-proxy");
|
|
8
|
-
var RepositoryImplementation_1 = require("./src/remult3/RepositoryImplementation");
|
|
9
|
-
var resultCompoundIdFilter_1 = require("./src/resultCompoundIdFilter");
|
|
10
|
-
var MongoDataProvider = /** @class */ (function () {
|
|
11
|
-
function MongoDataProvider(db, client, options) {
|
|
12
|
-
this.db = db;
|
|
13
|
-
this.client = client;
|
|
14
|
-
this.disableTransactions = false;
|
|
15
|
-
this.session = options === null || options === void 0 ? void 0 : options.session;
|
|
16
|
-
this.disableTransactions = options === null || options === void 0 ? void 0 : options.disableTransactions;
|
|
17
|
-
}
|
|
18
|
-
MongoDataProvider.getDb = function (remult) {
|
|
19
|
-
var r = (remult || remult_proxy_1.remult).dataProvider;
|
|
20
|
-
if (!r.db)
|
|
21
|
-
throw 'the data provider is not a MongoDataProvider';
|
|
22
|
-
return { db: r.db, session: r.session };
|
|
23
|
-
};
|
|
24
|
-
MongoDataProvider.prototype.getEntityDataProvider = function (entity) {
|
|
25
|
-
return new MongoEntityDataProvider(this.db, entity, this.session);
|
|
26
|
-
};
|
|
27
|
-
MongoDataProvider.prototype.transaction = function (action) {
|
|
28
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
29
|
-
var session, db, err_1;
|
|
30
|
-
return tslib_1.__generator(this, function (_a) {
|
|
31
|
-
switch (_a.label) {
|
|
32
|
-
case 0:
|
|
33
|
-
if (!this.disableTransactions) return [3 /*break*/, 2];
|
|
34
|
-
return [4 /*yield*/, action(this)];
|
|
35
|
-
case 1:
|
|
36
|
-
_a.sent();
|
|
37
|
-
return [3 /*break*/, 11];
|
|
38
|
-
case 2: return [4 /*yield*/, this.client.startSession()];
|
|
39
|
-
case 3:
|
|
40
|
-
session = _a.sent();
|
|
41
|
-
session.startTransaction();
|
|
42
|
-
db = this.client.db(this.db.databaseName);
|
|
43
|
-
_a.label = 4;
|
|
44
|
-
case 4:
|
|
45
|
-
_a.trys.push([4, 7, 9, 11]);
|
|
46
|
-
return [4 /*yield*/, action(new MongoDataProvider(db, undefined, { session: session }))];
|
|
47
|
-
case 5:
|
|
48
|
-
_a.sent();
|
|
49
|
-
return [4 /*yield*/, session.commitTransaction()];
|
|
50
|
-
case 6:
|
|
51
|
-
_a.sent();
|
|
52
|
-
return [3 /*break*/, 11];
|
|
53
|
-
case 7:
|
|
54
|
-
err_1 = _a.sent();
|
|
55
|
-
return [4 /*yield*/, session.abortTransaction()];
|
|
56
|
-
case 8:
|
|
57
|
-
_a.sent();
|
|
58
|
-
throw err_1;
|
|
59
|
-
case 9: return [4 /*yield*/, session.endSession()];
|
|
60
|
-
case 10:
|
|
61
|
-
_a.sent();
|
|
62
|
-
return [7 /*endfinally*/];
|
|
63
|
-
case 11: return [2 /*return*/];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
MongoDataProvider.filterToRaw = function (entity, condition) {
|
|
69
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
70
|
-
var repo, b, _a, r;
|
|
71
|
-
return tslib_1.__generator(this, function (_b) {
|
|
72
|
-
switch (_b.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
repo = RepositoryImplementation_1.getRepository(entity);
|
|
75
|
-
_a = FilterConsumerBridgeToMongo.bind;
|
|
76
|
-
return [4 /*yield*/, filter_consumer_bridge_to_sql_request_1.dbNamesOf(repo.metadata)];
|
|
77
|
-
case 1:
|
|
78
|
-
b = new (_a.apply(FilterConsumerBridgeToMongo, [void 0, _b.sent()]))();
|
|
79
|
-
b._addWhere = false;
|
|
80
|
-
return [4 /*yield*/, repo.translateWhereToFilter(condition)];
|
|
81
|
-
case 2: return [4 /*yield*/, (_b.sent()).__applyToConsumer(b)];
|
|
82
|
-
case 3:
|
|
83
|
-
_b.sent();
|
|
84
|
-
return [4 /*yield*/, b.resolveWhere()];
|
|
85
|
-
case 4:
|
|
86
|
-
r = _b.sent();
|
|
87
|
-
return [2 /*return*/, r];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
return MongoDataProvider;
|
|
93
|
-
}());
|
|
94
|
-
exports.MongoDataProvider = MongoDataProvider;
|
|
95
|
-
var NULL = { $null: '$null' };
|
|
96
|
-
function isNull(x) {
|
|
97
|
-
return (x === null || x === void 0 ? void 0 : x.$null) === NULL.$null;
|
|
98
|
-
}
|
|
99
|
-
var MongoEntityDataProvider = /** @class */ (function () {
|
|
100
|
-
function MongoEntityDataProvider(db, entity, session) {
|
|
101
|
-
this.db = db;
|
|
102
|
-
this.entity = entity;
|
|
103
|
-
this.session = session;
|
|
104
|
-
}
|
|
105
|
-
MongoEntityDataProvider.prototype.translateFromDb = function (row, nameProvider) {
|
|
106
|
-
var e_1, _a;
|
|
107
|
-
var result = {};
|
|
108
|
-
try {
|
|
109
|
-
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
110
|
-
var col = _c.value;
|
|
111
|
-
var val = row[nameProvider.$dbNameOf(col)];
|
|
112
|
-
if (isNull(val))
|
|
113
|
-
val = null;
|
|
114
|
-
result[col.key] = col.valueConverter.fromDb(val);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
118
|
-
finally {
|
|
119
|
-
try {
|
|
120
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
121
|
-
}
|
|
122
|
-
finally { if (e_1) throw e_1.error; }
|
|
123
|
-
}
|
|
124
|
-
return result;
|
|
125
|
-
};
|
|
126
|
-
MongoEntityDataProvider.prototype.translateToDb = function (row, nameProvider) {
|
|
127
|
-
var e_2, _a;
|
|
128
|
-
var result = {};
|
|
129
|
-
try {
|
|
130
|
-
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
131
|
-
var col = _c.value;
|
|
132
|
-
var val = col.valueConverter.toDb(row[col.key]);
|
|
133
|
-
if (val === null)
|
|
134
|
-
val = NULL;
|
|
135
|
-
result[nameProvider.$dbNameOf(col)] = val;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
139
|
-
finally {
|
|
140
|
-
try {
|
|
141
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
142
|
-
}
|
|
143
|
-
finally { if (e_2) throw e_2.error; }
|
|
144
|
-
}
|
|
145
|
-
return result;
|
|
146
|
-
};
|
|
147
|
-
MongoEntityDataProvider.prototype.count = function (where) {
|
|
148
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
149
|
-
var _a, collection, e, x, w;
|
|
150
|
-
return tslib_1.__generator(this, function (_b) {
|
|
151
|
-
switch (_b.label) {
|
|
152
|
-
case 0: return [4 /*yield*/, this.collection()];
|
|
153
|
-
case 1:
|
|
154
|
-
_a = _b.sent(), collection = _a.collection, e = _a.e;
|
|
155
|
-
x = new FilterConsumerBridgeToMongo(e);
|
|
156
|
-
where.__applyToConsumer(x);
|
|
157
|
-
return [4 /*yield*/, x.resolveWhere()];
|
|
158
|
-
case 2:
|
|
159
|
-
w = _b.sent();
|
|
160
|
-
return [4 /*yield*/, collection.countDocuments(w, { session: this.session })];
|
|
161
|
-
case 3: return [2 /*return*/, _b.sent()];
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
MongoEntityDataProvider.prototype.find = function (options) {
|
|
167
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
168
|
-
var _a, collection, e, x, where, op, _b, _c, s, _d, _e;
|
|
169
|
-
var e_3, _f;
|
|
170
|
-
var _this = this;
|
|
171
|
-
return tslib_1.__generator(this, function (_g) {
|
|
172
|
-
switch (_g.label) {
|
|
173
|
-
case 0: return [4 /*yield*/, this.collection()];
|
|
174
|
-
case 1:
|
|
175
|
-
_a = _g.sent(), collection = _a.collection, e = _a.e;
|
|
176
|
-
x = new FilterConsumerBridgeToMongo(e);
|
|
177
|
-
if (options === null || options === void 0 ? void 0 : options.where)
|
|
178
|
-
options.where.__applyToConsumer(x);
|
|
179
|
-
return [4 /*yield*/, x.resolveWhere()];
|
|
180
|
-
case 2:
|
|
181
|
-
where = _g.sent();
|
|
182
|
-
op = {
|
|
183
|
-
session: this.session,
|
|
184
|
-
};
|
|
185
|
-
if (options.limit) {
|
|
186
|
-
op.limit = options.limit;
|
|
187
|
-
if (options.page) {
|
|
188
|
-
op.skip = (options.page - 1) * options.limit;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (options.orderBy) {
|
|
192
|
-
op.sort = {};
|
|
193
|
-
try {
|
|
194
|
-
for (_b = tslib_1.__values(options.orderBy.Segments), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
195
|
-
s = _c.value;
|
|
196
|
-
op.sort[e.$dbNameOf(s.field)] = s.isDescending ? -1 : 1;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
200
|
-
finally {
|
|
201
|
-
try {
|
|
202
|
-
if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
|
|
203
|
-
}
|
|
204
|
-
finally { if (e_3) throw e_3.error; }
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
_e = (_d = Promise).all;
|
|
208
|
-
return [4 /*yield*/, collection
|
|
209
|
-
.find(where, op)
|
|
210
|
-
.map(function (x) { return _this.translateFromDb(x, e); })
|
|
211
|
-
.toArray()];
|
|
212
|
-
case 3: return [4 /*yield*/, _e.apply(_d, [_g.sent()])];
|
|
213
|
-
case 4: return [2 /*return*/, _g.sent()];
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
|
-
MongoEntityDataProvider.prototype.update = function (id, data) {
|
|
219
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
220
|
-
var _a, collection, e, f, resultFilter, _b, _c, x, newR, keys, _d, _e, f_1, r, _f, _g;
|
|
221
|
-
var e_4, _h, e_5, _j;
|
|
222
|
-
return tslib_1.__generator(this, function (_k) {
|
|
223
|
-
switch (_k.label) {
|
|
224
|
-
case 0: return [4 /*yield*/, this.collection()];
|
|
225
|
-
case 1:
|
|
226
|
-
_a = _k.sent(), collection = _a.collection, e = _a.e;
|
|
227
|
-
f = new FilterConsumerBridgeToMongo(e);
|
|
228
|
-
_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
229
|
-
resultFilter = this.entity.idMetadata.getIdFilter(id);
|
|
230
|
-
if (data.id != undefined)
|
|
231
|
-
resultFilter = this.entity.idMetadata.getIdFilter(data.id);
|
|
232
|
-
try {
|
|
233
|
-
for (_b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
234
|
-
x = _c.value;
|
|
235
|
-
if (x instanceof _1.CompoundIdField) {
|
|
236
|
-
resultFilter = resultCompoundIdFilter_1.resultCompoundIdFilter(x, id, data);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
241
|
-
finally {
|
|
242
|
-
try {
|
|
243
|
-
if (_c && !_c.done && (_h = _b.return)) _h.call(_b);
|
|
244
|
-
}
|
|
245
|
-
finally { if (e_4) throw e_4.error; }
|
|
246
|
-
}
|
|
247
|
-
newR = {};
|
|
248
|
-
keys = Object.keys(data);
|
|
249
|
-
try {
|
|
250
|
-
for (_d = tslib_1.__values(this.entity.fields), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
251
|
-
f_1 = _e.value;
|
|
252
|
-
if (!f_1.dbReadOnly && !f_1.isServerExpression) {
|
|
253
|
-
if (keys.includes(f_1.key)) {
|
|
254
|
-
newR[f_1.key] = f_1.valueConverter.toDb(data[f_1.key]);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
260
|
-
finally {
|
|
261
|
-
try {
|
|
262
|
-
if (_e && !_e.done && (_j = _d.return)) _j.call(_d);
|
|
263
|
-
}
|
|
264
|
-
finally { if (e_5) throw e_5.error; }
|
|
265
|
-
}
|
|
266
|
-
_g = (_f = collection).updateOne;
|
|
267
|
-
return [4 /*yield*/, f.resolveWhere()];
|
|
268
|
-
case 2: return [4 /*yield*/, _g.apply(_f, [_k.sent(), {
|
|
269
|
-
$set: newR,
|
|
270
|
-
},
|
|
271
|
-
{ session: this.session }])];
|
|
272
|
-
case 3:
|
|
273
|
-
r = _k.sent();
|
|
274
|
-
return [2 /*return*/, this.find({
|
|
275
|
-
where: _1.Filter.fromEntityFilter(this.entity, resultFilter),
|
|
276
|
-
}).then(function (y) { return y[0]; })];
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
MongoEntityDataProvider.prototype.delete = function (id) {
|
|
282
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
283
|
-
var _a, e, collection, f, _b, _c;
|
|
284
|
-
return tslib_1.__generator(this, function (_d) {
|
|
285
|
-
switch (_d.label) {
|
|
286
|
-
case 0: return [4 /*yield*/, this.collection()];
|
|
287
|
-
case 1:
|
|
288
|
-
_a = _d.sent(), e = _a.e, collection = _a.collection;
|
|
289
|
-
f = new FilterConsumerBridgeToMongo(e);
|
|
290
|
-
_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
291
|
-
_c = (_b = collection).deleteOne;
|
|
292
|
-
return [4 /*yield*/, f.resolveWhere()];
|
|
293
|
-
case 2:
|
|
294
|
-
_c.apply(_b, [_d.sent(), { session: this.session }]);
|
|
295
|
-
return [2 /*return*/];
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
MongoEntityDataProvider.prototype.insert = function (data) {
|
|
301
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
302
|
-
var _a, collection, e, r, _b, _c, _d;
|
|
303
|
-
return tslib_1.__generator(this, function (_e) {
|
|
304
|
-
switch (_e.label) {
|
|
305
|
-
case 0: return [4 /*yield*/, this.collection()];
|
|
306
|
-
case 1:
|
|
307
|
-
_a = _e.sent(), collection = _a.collection, e = _a.e;
|
|
308
|
-
_c = (_b = collection).insertOne;
|
|
309
|
-
return [4 /*yield*/, this.translateToDb(data, e)];
|
|
310
|
-
case 2: return [4 /*yield*/, _c.apply(_b, [_e.sent(), {
|
|
311
|
-
session: this.session,
|
|
312
|
-
}])];
|
|
313
|
-
case 3:
|
|
314
|
-
r = _e.sent();
|
|
315
|
-
_d = this.translateFromDb;
|
|
316
|
-
return [4 /*yield*/, collection.findOne({ _id: r.insertedId }, { session: this.session })];
|
|
317
|
-
case 4: return [4 /*yield*/, _d.apply(this, [_e.sent(), e])];
|
|
318
|
-
case 5: return [2 /*return*/, _e.sent()];
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
MongoEntityDataProvider.prototype.collection = function () {
|
|
324
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
325
|
-
var e, collection;
|
|
326
|
-
return tslib_1.__generator(this, function (_a) {
|
|
327
|
-
switch (_a.label) {
|
|
328
|
-
case 0: return [4 /*yield*/, filter_consumer_bridge_to_sql_request_1.dbNamesOf(this.entity)];
|
|
329
|
-
case 1:
|
|
330
|
-
e = _a.sent();
|
|
331
|
-
collection = this.db.collection(e.$entityName);
|
|
332
|
-
return [2 /*return*/, { e: e, collection: collection }];
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
return MongoEntityDataProvider;
|
|
338
|
-
}());
|
|
339
|
-
var FilterConsumerBridgeToMongo = /** @class */ (function () {
|
|
340
|
-
function FilterConsumerBridgeToMongo(nameProvider) {
|
|
341
|
-
this.nameProvider = nameProvider;
|
|
342
|
-
this._addWhere = true;
|
|
343
|
-
this.promises = [];
|
|
344
|
-
this.result = [];
|
|
345
|
-
}
|
|
346
|
-
FilterConsumerBridgeToMongo.prototype.resolveWhere = function () {
|
|
347
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
348
|
-
var p, p_1, p_1_1, pr, e_6_1;
|
|
349
|
-
var e_6, _a;
|
|
350
|
-
return tslib_1.__generator(this, function (_b) {
|
|
351
|
-
switch (_b.label) {
|
|
352
|
-
case 0:
|
|
353
|
-
if (!(this.promises.length > 0)) return [3 /*break*/, 9];
|
|
354
|
-
p = this.promises;
|
|
355
|
-
this.promises = [];
|
|
356
|
-
_b.label = 1;
|
|
357
|
-
case 1:
|
|
358
|
-
_b.trys.push([1, 6, 7, 8]);
|
|
359
|
-
p_1 = (e_6 = void 0, tslib_1.__values(p)), p_1_1 = p_1.next();
|
|
360
|
-
_b.label = 2;
|
|
361
|
-
case 2:
|
|
362
|
-
if (!!p_1_1.done) return [3 /*break*/, 5];
|
|
363
|
-
pr = p_1_1.value;
|
|
364
|
-
return [4 /*yield*/, pr];
|
|
365
|
-
case 3:
|
|
366
|
-
_b.sent();
|
|
367
|
-
_b.label = 4;
|
|
368
|
-
case 4:
|
|
369
|
-
p_1_1 = p_1.next();
|
|
370
|
-
return [3 /*break*/, 2];
|
|
371
|
-
case 5: return [3 /*break*/, 8];
|
|
372
|
-
case 6:
|
|
373
|
-
e_6_1 = _b.sent();
|
|
374
|
-
e_6 = { error: e_6_1 };
|
|
375
|
-
return [3 /*break*/, 8];
|
|
376
|
-
case 7:
|
|
377
|
-
try {
|
|
378
|
-
if (p_1_1 && !p_1_1.done && (_a = p_1.return)) _a.call(p_1);
|
|
379
|
-
}
|
|
380
|
-
finally { if (e_6) throw e_6.error; }
|
|
381
|
-
return [7 /*endfinally*/];
|
|
382
|
-
case 8: return [3 /*break*/, 0];
|
|
383
|
-
case 9:
|
|
384
|
-
if (this.result.length > 0)
|
|
385
|
-
return [2 /*return*/, { $and: this.result.map(function (x) { return x(); }) }];
|
|
386
|
-
else
|
|
387
|
-
return [2 /*return*/, {}];
|
|
388
|
-
return [2 /*return*/];
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
};
|
|
393
|
-
FilterConsumerBridgeToMongo.prototype.custom = function (key, customItem) {
|
|
394
|
-
throw new Error('Custom filter should be translated before it gets here');
|
|
395
|
-
};
|
|
396
|
-
FilterConsumerBridgeToMongo.prototype.or = function (orElements) {
|
|
397
|
-
var _this = this;
|
|
398
|
-
this.promises.push((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
399
|
-
var result, orElements_1, orElements_1_1, element, f, where, e_7_1;
|
|
400
|
-
var e_7, _a;
|
|
401
|
-
var _b;
|
|
402
|
-
return tslib_1.__generator(this, function (_c) {
|
|
403
|
-
switch (_c.label) {
|
|
404
|
-
case 0:
|
|
405
|
-
result = [];
|
|
406
|
-
_c.label = 1;
|
|
407
|
-
case 1:
|
|
408
|
-
_c.trys.push([1, 6, 7, 8]);
|
|
409
|
-
orElements_1 = tslib_1.__values(orElements), orElements_1_1 = orElements_1.next();
|
|
410
|
-
_c.label = 2;
|
|
411
|
-
case 2:
|
|
412
|
-
if (!!orElements_1_1.done) return [3 /*break*/, 5];
|
|
413
|
-
element = orElements_1_1.value;
|
|
414
|
-
f = new FilterConsumerBridgeToMongo(this.nameProvider);
|
|
415
|
-
f._addWhere = false;
|
|
416
|
-
element.__applyToConsumer(f);
|
|
417
|
-
return [4 /*yield*/, f.resolveWhere()];
|
|
418
|
-
case 3:
|
|
419
|
-
where = _c.sent();
|
|
420
|
-
if (((_b = where === null || where === void 0 ? void 0 : where.$and) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
421
|
-
result.push(where);
|
|
422
|
-
}
|
|
423
|
-
else
|
|
424
|
-
return [2 /*return*/]; //since empty or is all rows;
|
|
425
|
-
_c.label = 4;
|
|
426
|
-
case 4:
|
|
427
|
-
orElements_1_1 = orElements_1.next();
|
|
428
|
-
return [3 /*break*/, 2];
|
|
429
|
-
case 5: return [3 /*break*/, 8];
|
|
430
|
-
case 6:
|
|
431
|
-
e_7_1 = _c.sent();
|
|
432
|
-
e_7 = { error: e_7_1 };
|
|
433
|
-
return [3 /*break*/, 8];
|
|
434
|
-
case 7:
|
|
435
|
-
try {
|
|
436
|
-
if (orElements_1_1 && !orElements_1_1.done && (_a = orElements_1.return)) _a.call(orElements_1);
|
|
437
|
-
}
|
|
438
|
-
finally { if (e_7) throw e_7.error; }
|
|
439
|
-
return [7 /*endfinally*/];
|
|
440
|
-
case 8:
|
|
441
|
-
this.result.push(function () { return ({
|
|
442
|
-
$or: result,
|
|
443
|
-
}); });
|
|
444
|
-
return [2 /*return*/];
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
}); })());
|
|
448
|
-
};
|
|
449
|
-
FilterConsumerBridgeToMongo.prototype.isNull = function (col) {
|
|
450
|
-
this.add(col, NULL, '$eq');
|
|
451
|
-
};
|
|
452
|
-
FilterConsumerBridgeToMongo.prototype.isNotNull = function (col) {
|
|
453
|
-
this.add(col, NULL, '$ne');
|
|
454
|
-
};
|
|
455
|
-
FilterConsumerBridgeToMongo.prototype.isIn = function (col, val) {
|
|
456
|
-
var _this = this;
|
|
457
|
-
this.result.push(function () {
|
|
458
|
-
var _a;
|
|
459
|
-
return (_a = {},
|
|
460
|
-
_a[_this.nameProvider.$dbNameOf(col)] = {
|
|
461
|
-
$in: val.map(function (x) { return col.valueConverter.toDb(x); }),
|
|
462
|
-
},
|
|
463
|
-
_a);
|
|
464
|
-
});
|
|
465
|
-
};
|
|
466
|
-
FilterConsumerBridgeToMongo.prototype.isEqualTo = function (col, val) {
|
|
467
|
-
this.add(col, val, '$eq');
|
|
468
|
-
};
|
|
469
|
-
FilterConsumerBridgeToMongo.prototype.isDifferentFrom = function (col, val) {
|
|
470
|
-
this.add(col, val, '$ne');
|
|
471
|
-
};
|
|
472
|
-
FilterConsumerBridgeToMongo.prototype.isGreaterOrEqualTo = function (col, val) {
|
|
473
|
-
this.add(col, val, '$gte');
|
|
474
|
-
};
|
|
475
|
-
FilterConsumerBridgeToMongo.prototype.isGreaterThan = function (col, val) {
|
|
476
|
-
this.add(col, val, '$gt');
|
|
477
|
-
};
|
|
478
|
-
FilterConsumerBridgeToMongo.prototype.isLessOrEqualTo = function (col, val) {
|
|
479
|
-
this.add(col, val, '$lte');
|
|
480
|
-
};
|
|
481
|
-
FilterConsumerBridgeToMongo.prototype.isLessThan = function (col, val) {
|
|
482
|
-
this.add(col, val, '$lt');
|
|
483
|
-
};
|
|
484
|
-
FilterConsumerBridgeToMongo.prototype.containsCaseInsensitive = function (col, val) {
|
|
485
|
-
this.add(col, val, '$regex');
|
|
486
|
-
// this.promises.push(col.getDbName().then(colName => {
|
|
487
|
-
// this.result.push(b => b.whereRaw(
|
|
488
|
-
// 'lower (' + colName + ") like lower ('%" + val.replace(/'/g, '\'\'') + "%')"));
|
|
489
|
-
// }));
|
|
490
|
-
};
|
|
491
|
-
FilterConsumerBridgeToMongo.prototype.add = function (col, val, operator) {
|
|
492
|
-
var _this = this;
|
|
493
|
-
this.result.push(function () {
|
|
494
|
-
var _a, _b;
|
|
495
|
-
return (_a = {},
|
|
496
|
-
_a[_this.nameProvider.$dbNameOf(col)] = (_b = {},
|
|
497
|
-
_b[operator] = isNull(val) ? val : col.valueConverter.toDb(val),
|
|
498
|
-
_b),
|
|
499
|
-
_a);
|
|
500
|
-
});
|
|
501
|
-
};
|
|
502
|
-
FilterConsumerBridgeToMongo.prototype.databaseCustom = function (databaseCustom) {
|
|
503
|
-
throw 'error';
|
|
504
|
-
// this.promises.push((async () => {
|
|
505
|
-
// if (databaseCustom?.buildSql) {
|
|
506
|
-
// let item = new CustomSqlFilterBuilder(this.knex);
|
|
507
|
-
// await databaseCustom.buildSql(item);
|
|
508
|
-
// if (item.sql) {
|
|
509
|
-
// this.addToWhere("(" + item.sql + ")");
|
|
510
|
-
// }
|
|
511
|
-
// }
|
|
512
|
-
// })());
|
|
513
|
-
};
|
|
514
|
-
return FilterConsumerBridgeToMongo;
|
|
515
|
-
}());
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoDataProvider = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var _1 = require(".");
|
|
6
|
+
var filter_consumer_bridge_to_sql_request_1 = require("./src/filter/filter-consumer-bridge-to-sql-request");
|
|
7
|
+
var remult_proxy_1 = require("./src/remult-proxy");
|
|
8
|
+
var RepositoryImplementation_1 = require("./src/remult3/RepositoryImplementation");
|
|
9
|
+
var resultCompoundIdFilter_1 = require("./src/resultCompoundIdFilter");
|
|
10
|
+
var MongoDataProvider = /** @class */ (function () {
|
|
11
|
+
function MongoDataProvider(db, client, options) {
|
|
12
|
+
this.db = db;
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.disableTransactions = false;
|
|
15
|
+
this.session = options === null || options === void 0 ? void 0 : options.session;
|
|
16
|
+
this.disableTransactions = options === null || options === void 0 ? void 0 : options.disableTransactions;
|
|
17
|
+
}
|
|
18
|
+
MongoDataProvider.getDb = function (remult) {
|
|
19
|
+
var r = (remult || remult_proxy_1.remult).dataProvider;
|
|
20
|
+
if (!r.db)
|
|
21
|
+
throw 'the data provider is not a MongoDataProvider';
|
|
22
|
+
return { db: r.db, session: r.session };
|
|
23
|
+
};
|
|
24
|
+
MongoDataProvider.prototype.getEntityDataProvider = function (entity) {
|
|
25
|
+
return new MongoEntityDataProvider(this.db, entity, this.session);
|
|
26
|
+
};
|
|
27
|
+
MongoDataProvider.prototype.transaction = function (action) {
|
|
28
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
29
|
+
var session, db, err_1;
|
|
30
|
+
return tslib_1.__generator(this, function (_a) {
|
|
31
|
+
switch (_a.label) {
|
|
32
|
+
case 0:
|
|
33
|
+
if (!this.disableTransactions) return [3 /*break*/, 2];
|
|
34
|
+
return [4 /*yield*/, action(this)];
|
|
35
|
+
case 1:
|
|
36
|
+
_a.sent();
|
|
37
|
+
return [3 /*break*/, 11];
|
|
38
|
+
case 2: return [4 /*yield*/, this.client.startSession()];
|
|
39
|
+
case 3:
|
|
40
|
+
session = _a.sent();
|
|
41
|
+
session.startTransaction();
|
|
42
|
+
db = this.client.db(this.db.databaseName);
|
|
43
|
+
_a.label = 4;
|
|
44
|
+
case 4:
|
|
45
|
+
_a.trys.push([4, 7, 9, 11]);
|
|
46
|
+
return [4 /*yield*/, action(new MongoDataProvider(db, undefined, { session: session }))];
|
|
47
|
+
case 5:
|
|
48
|
+
_a.sent();
|
|
49
|
+
return [4 /*yield*/, session.commitTransaction()];
|
|
50
|
+
case 6:
|
|
51
|
+
_a.sent();
|
|
52
|
+
return [3 /*break*/, 11];
|
|
53
|
+
case 7:
|
|
54
|
+
err_1 = _a.sent();
|
|
55
|
+
return [4 /*yield*/, session.abortTransaction()];
|
|
56
|
+
case 8:
|
|
57
|
+
_a.sent();
|
|
58
|
+
throw err_1;
|
|
59
|
+
case 9: return [4 /*yield*/, session.endSession()];
|
|
60
|
+
case 10:
|
|
61
|
+
_a.sent();
|
|
62
|
+
return [7 /*endfinally*/];
|
|
63
|
+
case 11: return [2 /*return*/];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
MongoDataProvider.filterToRaw = function (entity, condition) {
|
|
69
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var repo, b, _a, r;
|
|
71
|
+
return tslib_1.__generator(this, function (_b) {
|
|
72
|
+
switch (_b.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
repo = (0, RepositoryImplementation_1.getRepository)(entity);
|
|
75
|
+
_a = FilterConsumerBridgeToMongo.bind;
|
|
76
|
+
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_1.dbNamesOf)(repo.metadata)];
|
|
77
|
+
case 1:
|
|
78
|
+
b = new (_a.apply(FilterConsumerBridgeToMongo, [void 0, _b.sent()]))();
|
|
79
|
+
b._addWhere = false;
|
|
80
|
+
return [4 /*yield*/, repo.translateWhereToFilter(condition)];
|
|
81
|
+
case 2: return [4 /*yield*/, (_b.sent()).__applyToConsumer(b)];
|
|
82
|
+
case 3:
|
|
83
|
+
_b.sent();
|
|
84
|
+
return [4 /*yield*/, b.resolveWhere()];
|
|
85
|
+
case 4:
|
|
86
|
+
r = _b.sent();
|
|
87
|
+
return [2 /*return*/, r];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
return MongoDataProvider;
|
|
93
|
+
}());
|
|
94
|
+
exports.MongoDataProvider = MongoDataProvider;
|
|
95
|
+
var NULL = { $null: '$null' };
|
|
96
|
+
function isNull(x) {
|
|
97
|
+
return (x === null || x === void 0 ? void 0 : x.$null) === NULL.$null;
|
|
98
|
+
}
|
|
99
|
+
var MongoEntityDataProvider = /** @class */ (function () {
|
|
100
|
+
function MongoEntityDataProvider(db, entity, session) {
|
|
101
|
+
this.db = db;
|
|
102
|
+
this.entity = entity;
|
|
103
|
+
this.session = session;
|
|
104
|
+
}
|
|
105
|
+
MongoEntityDataProvider.prototype.translateFromDb = function (row, nameProvider) {
|
|
106
|
+
var e_1, _a;
|
|
107
|
+
var result = {};
|
|
108
|
+
try {
|
|
109
|
+
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
110
|
+
var col = _c.value;
|
|
111
|
+
var val = row[nameProvider.$dbNameOf(col)];
|
|
112
|
+
if (isNull(val))
|
|
113
|
+
val = null;
|
|
114
|
+
result[col.key] = col.valueConverter.fromDb(val);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
118
|
+
finally {
|
|
119
|
+
try {
|
|
120
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
121
|
+
}
|
|
122
|
+
finally { if (e_1) throw e_1.error; }
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
};
|
|
126
|
+
MongoEntityDataProvider.prototype.translateToDb = function (row, nameProvider) {
|
|
127
|
+
var e_2, _a;
|
|
128
|
+
var result = {};
|
|
129
|
+
try {
|
|
130
|
+
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
131
|
+
var col = _c.value;
|
|
132
|
+
var val = col.valueConverter.toDb(row[col.key]);
|
|
133
|
+
if (val === null)
|
|
134
|
+
val = NULL;
|
|
135
|
+
result[nameProvider.$dbNameOf(col)] = val;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
139
|
+
finally {
|
|
140
|
+
try {
|
|
141
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
142
|
+
}
|
|
143
|
+
finally { if (e_2) throw e_2.error; }
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
};
|
|
147
|
+
MongoEntityDataProvider.prototype.count = function (where) {
|
|
148
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
149
|
+
var _a, collection, e, x, w;
|
|
150
|
+
return tslib_1.__generator(this, function (_b) {
|
|
151
|
+
switch (_b.label) {
|
|
152
|
+
case 0: return [4 /*yield*/, this.collection()];
|
|
153
|
+
case 1:
|
|
154
|
+
_a = _b.sent(), collection = _a.collection, e = _a.e;
|
|
155
|
+
x = new FilterConsumerBridgeToMongo(e);
|
|
156
|
+
where.__applyToConsumer(x);
|
|
157
|
+
return [4 /*yield*/, x.resolveWhere()];
|
|
158
|
+
case 2:
|
|
159
|
+
w = _b.sent();
|
|
160
|
+
return [4 /*yield*/, collection.countDocuments(w, { session: this.session })];
|
|
161
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
MongoEntityDataProvider.prototype.find = function (options) {
|
|
167
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var _a, collection, e, x, where, op, _b, _c, s, _d, _e;
|
|
169
|
+
var e_3, _f;
|
|
170
|
+
var _this = this;
|
|
171
|
+
return tslib_1.__generator(this, function (_g) {
|
|
172
|
+
switch (_g.label) {
|
|
173
|
+
case 0: return [4 /*yield*/, this.collection()];
|
|
174
|
+
case 1:
|
|
175
|
+
_a = _g.sent(), collection = _a.collection, e = _a.e;
|
|
176
|
+
x = new FilterConsumerBridgeToMongo(e);
|
|
177
|
+
if (options === null || options === void 0 ? void 0 : options.where)
|
|
178
|
+
options.where.__applyToConsumer(x);
|
|
179
|
+
return [4 /*yield*/, x.resolveWhere()];
|
|
180
|
+
case 2:
|
|
181
|
+
where = _g.sent();
|
|
182
|
+
op = {
|
|
183
|
+
session: this.session,
|
|
184
|
+
};
|
|
185
|
+
if (options.limit) {
|
|
186
|
+
op.limit = options.limit;
|
|
187
|
+
if (options.page) {
|
|
188
|
+
op.skip = (options.page - 1) * options.limit;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (options.orderBy) {
|
|
192
|
+
op.sort = {};
|
|
193
|
+
try {
|
|
194
|
+
for (_b = tslib_1.__values(options.orderBy.Segments), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
195
|
+
s = _c.value;
|
|
196
|
+
op.sort[e.$dbNameOf(s.field)] = s.isDescending ? -1 : 1;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
200
|
+
finally {
|
|
201
|
+
try {
|
|
202
|
+
if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
|
|
203
|
+
}
|
|
204
|
+
finally { if (e_3) throw e_3.error; }
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
_e = (_d = Promise).all;
|
|
208
|
+
return [4 /*yield*/, collection
|
|
209
|
+
.find(where, op)
|
|
210
|
+
.map(function (x) { return _this.translateFromDb(x, e); })
|
|
211
|
+
.toArray()];
|
|
212
|
+
case 3: return [4 /*yield*/, _e.apply(_d, [_g.sent()])];
|
|
213
|
+
case 4: return [2 /*return*/, _g.sent()];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
MongoEntityDataProvider.prototype.update = function (id, data) {
|
|
219
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
220
|
+
var _a, collection, e, f, resultFilter, _b, _c, x, newR, keys, _d, _e, f_1, r, _f, _g;
|
|
221
|
+
var e_4, _h, e_5, _j;
|
|
222
|
+
return tslib_1.__generator(this, function (_k) {
|
|
223
|
+
switch (_k.label) {
|
|
224
|
+
case 0: return [4 /*yield*/, this.collection()];
|
|
225
|
+
case 1:
|
|
226
|
+
_a = _k.sent(), collection = _a.collection, e = _a.e;
|
|
227
|
+
f = new FilterConsumerBridgeToMongo(e);
|
|
228
|
+
_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
229
|
+
resultFilter = this.entity.idMetadata.getIdFilter(id);
|
|
230
|
+
if (data.id != undefined)
|
|
231
|
+
resultFilter = this.entity.idMetadata.getIdFilter(data.id);
|
|
232
|
+
try {
|
|
233
|
+
for (_b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
234
|
+
x = _c.value;
|
|
235
|
+
if (x instanceof _1.CompoundIdField) {
|
|
236
|
+
resultFilter = (0, resultCompoundIdFilter_1.resultCompoundIdFilter)(x, id, data);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
241
|
+
finally {
|
|
242
|
+
try {
|
|
243
|
+
if (_c && !_c.done && (_h = _b.return)) _h.call(_b);
|
|
244
|
+
}
|
|
245
|
+
finally { if (e_4) throw e_4.error; }
|
|
246
|
+
}
|
|
247
|
+
newR = {};
|
|
248
|
+
keys = Object.keys(data);
|
|
249
|
+
try {
|
|
250
|
+
for (_d = tslib_1.__values(this.entity.fields), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
251
|
+
f_1 = _e.value;
|
|
252
|
+
if (!f_1.dbReadOnly && !f_1.isServerExpression) {
|
|
253
|
+
if (keys.includes(f_1.key)) {
|
|
254
|
+
newR[f_1.key] = f_1.valueConverter.toDb(data[f_1.key]);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
260
|
+
finally {
|
|
261
|
+
try {
|
|
262
|
+
if (_e && !_e.done && (_j = _d.return)) _j.call(_d);
|
|
263
|
+
}
|
|
264
|
+
finally { if (e_5) throw e_5.error; }
|
|
265
|
+
}
|
|
266
|
+
_g = (_f = collection).updateOne;
|
|
267
|
+
return [4 /*yield*/, f.resolveWhere()];
|
|
268
|
+
case 2: return [4 /*yield*/, _g.apply(_f, [_k.sent(), {
|
|
269
|
+
$set: newR,
|
|
270
|
+
},
|
|
271
|
+
{ session: this.session }])];
|
|
272
|
+
case 3:
|
|
273
|
+
r = _k.sent();
|
|
274
|
+
return [2 /*return*/, this.find({
|
|
275
|
+
where: _1.Filter.fromEntityFilter(this.entity, resultFilter),
|
|
276
|
+
}).then(function (y) { return y[0]; })];
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
MongoEntityDataProvider.prototype.delete = function (id) {
|
|
282
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
283
|
+
var _a, e, collection, f, _b, _c;
|
|
284
|
+
return tslib_1.__generator(this, function (_d) {
|
|
285
|
+
switch (_d.label) {
|
|
286
|
+
case 0: return [4 /*yield*/, this.collection()];
|
|
287
|
+
case 1:
|
|
288
|
+
_a = _d.sent(), e = _a.e, collection = _a.collection;
|
|
289
|
+
f = new FilterConsumerBridgeToMongo(e);
|
|
290
|
+
_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
291
|
+
_c = (_b = collection).deleteOne;
|
|
292
|
+
return [4 /*yield*/, f.resolveWhere()];
|
|
293
|
+
case 2:
|
|
294
|
+
_c.apply(_b, [_d.sent(), { session: this.session }]);
|
|
295
|
+
return [2 /*return*/];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
MongoEntityDataProvider.prototype.insert = function (data) {
|
|
301
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
302
|
+
var _a, collection, e, r, _b, _c, _d;
|
|
303
|
+
return tslib_1.__generator(this, function (_e) {
|
|
304
|
+
switch (_e.label) {
|
|
305
|
+
case 0: return [4 /*yield*/, this.collection()];
|
|
306
|
+
case 1:
|
|
307
|
+
_a = _e.sent(), collection = _a.collection, e = _a.e;
|
|
308
|
+
_c = (_b = collection).insertOne;
|
|
309
|
+
return [4 /*yield*/, this.translateToDb(data, e)];
|
|
310
|
+
case 2: return [4 /*yield*/, _c.apply(_b, [_e.sent(), {
|
|
311
|
+
session: this.session,
|
|
312
|
+
}])];
|
|
313
|
+
case 3:
|
|
314
|
+
r = _e.sent();
|
|
315
|
+
_d = this.translateFromDb;
|
|
316
|
+
return [4 /*yield*/, collection.findOne({ _id: r.insertedId }, { session: this.session })];
|
|
317
|
+
case 4: return [4 /*yield*/, _d.apply(this, [_e.sent(), e])];
|
|
318
|
+
case 5: return [2 /*return*/, _e.sent()];
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
MongoEntityDataProvider.prototype.collection = function () {
|
|
324
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
325
|
+
var e, collection;
|
|
326
|
+
return tslib_1.__generator(this, function (_a) {
|
|
327
|
+
switch (_a.label) {
|
|
328
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_1.dbNamesOf)(this.entity)];
|
|
329
|
+
case 1:
|
|
330
|
+
e = _a.sent();
|
|
331
|
+
collection = this.db.collection(e.$entityName);
|
|
332
|
+
return [2 /*return*/, { e: e, collection: collection }];
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
return MongoEntityDataProvider;
|
|
338
|
+
}());
|
|
339
|
+
var FilterConsumerBridgeToMongo = /** @class */ (function () {
|
|
340
|
+
function FilterConsumerBridgeToMongo(nameProvider) {
|
|
341
|
+
this.nameProvider = nameProvider;
|
|
342
|
+
this._addWhere = true;
|
|
343
|
+
this.promises = [];
|
|
344
|
+
this.result = [];
|
|
345
|
+
}
|
|
346
|
+
FilterConsumerBridgeToMongo.prototype.resolveWhere = function () {
|
|
347
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
348
|
+
var p, p_1, p_1_1, pr, e_6_1;
|
|
349
|
+
var e_6, _a;
|
|
350
|
+
return tslib_1.__generator(this, function (_b) {
|
|
351
|
+
switch (_b.label) {
|
|
352
|
+
case 0:
|
|
353
|
+
if (!(this.promises.length > 0)) return [3 /*break*/, 9];
|
|
354
|
+
p = this.promises;
|
|
355
|
+
this.promises = [];
|
|
356
|
+
_b.label = 1;
|
|
357
|
+
case 1:
|
|
358
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
359
|
+
p_1 = (e_6 = void 0, tslib_1.__values(p)), p_1_1 = p_1.next();
|
|
360
|
+
_b.label = 2;
|
|
361
|
+
case 2:
|
|
362
|
+
if (!!p_1_1.done) return [3 /*break*/, 5];
|
|
363
|
+
pr = p_1_1.value;
|
|
364
|
+
return [4 /*yield*/, pr];
|
|
365
|
+
case 3:
|
|
366
|
+
_b.sent();
|
|
367
|
+
_b.label = 4;
|
|
368
|
+
case 4:
|
|
369
|
+
p_1_1 = p_1.next();
|
|
370
|
+
return [3 /*break*/, 2];
|
|
371
|
+
case 5: return [3 /*break*/, 8];
|
|
372
|
+
case 6:
|
|
373
|
+
e_6_1 = _b.sent();
|
|
374
|
+
e_6 = { error: e_6_1 };
|
|
375
|
+
return [3 /*break*/, 8];
|
|
376
|
+
case 7:
|
|
377
|
+
try {
|
|
378
|
+
if (p_1_1 && !p_1_1.done && (_a = p_1.return)) _a.call(p_1);
|
|
379
|
+
}
|
|
380
|
+
finally { if (e_6) throw e_6.error; }
|
|
381
|
+
return [7 /*endfinally*/];
|
|
382
|
+
case 8: return [3 /*break*/, 0];
|
|
383
|
+
case 9:
|
|
384
|
+
if (this.result.length > 0)
|
|
385
|
+
return [2 /*return*/, { $and: this.result.map(function (x) { return x(); }) }];
|
|
386
|
+
else
|
|
387
|
+
return [2 /*return*/, {}];
|
|
388
|
+
return [2 /*return*/];
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
};
|
|
393
|
+
FilterConsumerBridgeToMongo.prototype.custom = function (key, customItem) {
|
|
394
|
+
throw new Error('Custom filter should be translated before it gets here');
|
|
395
|
+
};
|
|
396
|
+
FilterConsumerBridgeToMongo.prototype.or = function (orElements) {
|
|
397
|
+
var _this = this;
|
|
398
|
+
this.promises.push((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
399
|
+
var result, orElements_1, orElements_1_1, element, f, where, e_7_1;
|
|
400
|
+
var e_7, _a;
|
|
401
|
+
var _b;
|
|
402
|
+
return tslib_1.__generator(this, function (_c) {
|
|
403
|
+
switch (_c.label) {
|
|
404
|
+
case 0:
|
|
405
|
+
result = [];
|
|
406
|
+
_c.label = 1;
|
|
407
|
+
case 1:
|
|
408
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
409
|
+
orElements_1 = tslib_1.__values(orElements), orElements_1_1 = orElements_1.next();
|
|
410
|
+
_c.label = 2;
|
|
411
|
+
case 2:
|
|
412
|
+
if (!!orElements_1_1.done) return [3 /*break*/, 5];
|
|
413
|
+
element = orElements_1_1.value;
|
|
414
|
+
f = new FilterConsumerBridgeToMongo(this.nameProvider);
|
|
415
|
+
f._addWhere = false;
|
|
416
|
+
element.__applyToConsumer(f);
|
|
417
|
+
return [4 /*yield*/, f.resolveWhere()];
|
|
418
|
+
case 3:
|
|
419
|
+
where = _c.sent();
|
|
420
|
+
if (((_b = where === null || where === void 0 ? void 0 : where.$and) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
421
|
+
result.push(where);
|
|
422
|
+
}
|
|
423
|
+
else
|
|
424
|
+
return [2 /*return*/]; //since empty or is all rows;
|
|
425
|
+
_c.label = 4;
|
|
426
|
+
case 4:
|
|
427
|
+
orElements_1_1 = orElements_1.next();
|
|
428
|
+
return [3 /*break*/, 2];
|
|
429
|
+
case 5: return [3 /*break*/, 8];
|
|
430
|
+
case 6:
|
|
431
|
+
e_7_1 = _c.sent();
|
|
432
|
+
e_7 = { error: e_7_1 };
|
|
433
|
+
return [3 /*break*/, 8];
|
|
434
|
+
case 7:
|
|
435
|
+
try {
|
|
436
|
+
if (orElements_1_1 && !orElements_1_1.done && (_a = orElements_1.return)) _a.call(orElements_1);
|
|
437
|
+
}
|
|
438
|
+
finally { if (e_7) throw e_7.error; }
|
|
439
|
+
return [7 /*endfinally*/];
|
|
440
|
+
case 8:
|
|
441
|
+
this.result.push(function () { return ({
|
|
442
|
+
$or: result,
|
|
443
|
+
}); });
|
|
444
|
+
return [2 /*return*/];
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}); })());
|
|
448
|
+
};
|
|
449
|
+
FilterConsumerBridgeToMongo.prototype.isNull = function (col) {
|
|
450
|
+
this.add(col, NULL, '$eq');
|
|
451
|
+
};
|
|
452
|
+
FilterConsumerBridgeToMongo.prototype.isNotNull = function (col) {
|
|
453
|
+
this.add(col, NULL, '$ne');
|
|
454
|
+
};
|
|
455
|
+
FilterConsumerBridgeToMongo.prototype.isIn = function (col, val) {
|
|
456
|
+
var _this = this;
|
|
457
|
+
this.result.push(function () {
|
|
458
|
+
var _a;
|
|
459
|
+
return (_a = {},
|
|
460
|
+
_a[_this.nameProvider.$dbNameOf(col)] = {
|
|
461
|
+
$in: val.map(function (x) { return col.valueConverter.toDb(x); }),
|
|
462
|
+
},
|
|
463
|
+
_a);
|
|
464
|
+
});
|
|
465
|
+
};
|
|
466
|
+
FilterConsumerBridgeToMongo.prototype.isEqualTo = function (col, val) {
|
|
467
|
+
this.add(col, val, '$eq');
|
|
468
|
+
};
|
|
469
|
+
FilterConsumerBridgeToMongo.prototype.isDifferentFrom = function (col, val) {
|
|
470
|
+
this.add(col, val, '$ne');
|
|
471
|
+
};
|
|
472
|
+
FilterConsumerBridgeToMongo.prototype.isGreaterOrEqualTo = function (col, val) {
|
|
473
|
+
this.add(col, val, '$gte');
|
|
474
|
+
};
|
|
475
|
+
FilterConsumerBridgeToMongo.prototype.isGreaterThan = function (col, val) {
|
|
476
|
+
this.add(col, val, '$gt');
|
|
477
|
+
};
|
|
478
|
+
FilterConsumerBridgeToMongo.prototype.isLessOrEqualTo = function (col, val) {
|
|
479
|
+
this.add(col, val, '$lte');
|
|
480
|
+
};
|
|
481
|
+
FilterConsumerBridgeToMongo.prototype.isLessThan = function (col, val) {
|
|
482
|
+
this.add(col, val, '$lt');
|
|
483
|
+
};
|
|
484
|
+
FilterConsumerBridgeToMongo.prototype.containsCaseInsensitive = function (col, val) {
|
|
485
|
+
this.add(col, val, '$regex');
|
|
486
|
+
// this.promises.push(col.getDbName().then(colName => {
|
|
487
|
+
// this.result.push(b => b.whereRaw(
|
|
488
|
+
// 'lower (' + colName + ") like lower ('%" + val.replace(/'/g, '\'\'') + "%')"));
|
|
489
|
+
// }));
|
|
490
|
+
};
|
|
491
|
+
FilterConsumerBridgeToMongo.prototype.add = function (col, val, operator) {
|
|
492
|
+
var _this = this;
|
|
493
|
+
this.result.push(function () {
|
|
494
|
+
var _a, _b;
|
|
495
|
+
return (_a = {},
|
|
496
|
+
_a[_this.nameProvider.$dbNameOf(col)] = (_b = {},
|
|
497
|
+
_b[operator] = isNull(val) ? val : col.valueConverter.toDb(val),
|
|
498
|
+
_b),
|
|
499
|
+
_a);
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
FilterConsumerBridgeToMongo.prototype.databaseCustom = function (databaseCustom) {
|
|
503
|
+
throw 'error';
|
|
504
|
+
// this.promises.push((async () => {
|
|
505
|
+
// if (databaseCustom?.buildSql) {
|
|
506
|
+
// let item = new CustomSqlFilterBuilder(this.knex);
|
|
507
|
+
// await databaseCustom.buildSql(item);
|
|
508
|
+
// if (item.sql) {
|
|
509
|
+
// this.addToWhere("(" + item.sql + ")");
|
|
510
|
+
// }
|
|
511
|
+
// }
|
|
512
|
+
// })());
|
|
513
|
+
};
|
|
514
|
+
return FilterConsumerBridgeToMongo;
|
|
515
|
+
}());
|