remult 0.11.1 → 0.11.2
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/package.json +1 -1
- package/postgres/postgres-data-provider.d.ts +3 -3
- package/postgres/postgres-data-provider.js +136 -190
- package/remult-knex/index.d.ts +6 -5
- package/remult-knex/index.js +243 -286
- package/remult-mongo.js +150 -217
- package/server/expressBridge.js +1 -1
- package/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +1 -1
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +75 -52
- package/src/data-providers/sql-database.d.ts +0 -2
- package/src/data-providers/sql-database.js +199 -298
- package/src/data-providers/web-sql-data-provider.js +38 -56
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +15 -1
- package/src/filter/filter-consumer-bridge-to-sql-request.js +80 -50
- package/src/shared-tests/db-tests.db-tests.js +2 -2
- package/src/tests/entityForCustomFilter.js +24 -22
- package/valueConverters.js +1 -1
package/remult-mongo.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MongoDataProvider = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var _1 = require(".");
|
|
6
|
+
var filter_consumer_bridge_to_sql_request_1 = require("./src/filter/filter-consumer-bridge-to-sql-request");
|
|
6
7
|
var MongoDataProvider = /** @class */ (function () {
|
|
7
8
|
function MongoDataProvider(db, client) {
|
|
8
9
|
this.db = db;
|
|
@@ -53,123 +54,77 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
53
54
|
this.db = db;
|
|
54
55
|
this.entity = entity;
|
|
55
56
|
}
|
|
56
|
-
MongoEntityDataProvider.prototype.translateFromJson = function (row) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_g = row;
|
|
76
|
-
return [4 /*yield*/, col.getDbName()];
|
|
77
|
-
case 3:
|
|
78
|
-
_c[_d] = _f.apply(_e, [_g[_j.sent()]]);
|
|
79
|
-
if (isNull(result[col.key]))
|
|
80
|
-
result[col.key] = null;
|
|
81
|
-
_j.label = 4;
|
|
82
|
-
case 4:
|
|
83
|
-
_b = _a.next();
|
|
84
|
-
return [3 /*break*/, 2];
|
|
85
|
-
case 5: return [3 /*break*/, 8];
|
|
86
|
-
case 6:
|
|
87
|
-
e_1_1 = _j.sent();
|
|
88
|
-
e_1 = { error: e_1_1 };
|
|
89
|
-
return [3 /*break*/, 8];
|
|
90
|
-
case 7:
|
|
91
|
-
try {
|
|
92
|
-
if (_b && !_b.done && (_h = _a.return)) _h.call(_a);
|
|
93
|
-
}
|
|
94
|
-
finally { if (e_1) throw e_1.error; }
|
|
95
|
-
return [7 /*endfinally*/];
|
|
96
|
-
case 8: return [2 /*return*/, result];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
57
|
+
MongoEntityDataProvider.prototype.translateFromJson = function (row, nameProvider) {
|
|
58
|
+
var e_1, _a;
|
|
59
|
+
var result = {};
|
|
60
|
+
try {
|
|
61
|
+
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
62
|
+
var col = _c.value;
|
|
63
|
+
result[col.key] = col.valueConverter.fromDb(row[nameProvider.nameOf(col)]);
|
|
64
|
+
if (isNull(result[col.key]))
|
|
65
|
+
result[col.key] = null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
69
|
+
finally {
|
|
70
|
+
try {
|
|
71
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
72
|
+
}
|
|
73
|
+
finally { if (e_1) throw e_1.error; }
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
100
76
|
};
|
|
101
|
-
MongoEntityDataProvider.prototype.translateToJson = function (row) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return [4 /*yield*/, col.getDbName()];
|
|
122
|
-
case 3:
|
|
123
|
-
_c[_e.sent()] = val;
|
|
124
|
-
_e.label = 4;
|
|
125
|
-
case 4:
|
|
126
|
-
_b = _a.next();
|
|
127
|
-
return [3 /*break*/, 2];
|
|
128
|
-
case 5: return [3 /*break*/, 8];
|
|
129
|
-
case 6:
|
|
130
|
-
e_2_1 = _e.sent();
|
|
131
|
-
e_2 = { error: e_2_1 };
|
|
132
|
-
return [3 /*break*/, 8];
|
|
133
|
-
case 7:
|
|
134
|
-
try {
|
|
135
|
-
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
136
|
-
}
|
|
137
|
-
finally { if (e_2) throw e_2.error; }
|
|
138
|
-
return [7 /*endfinally*/];
|
|
139
|
-
case 8: return [2 /*return*/, result];
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
});
|
|
77
|
+
MongoEntityDataProvider.prototype.translateToJson = function (row, nameProvider) {
|
|
78
|
+
var e_2, _a;
|
|
79
|
+
var result = {};
|
|
80
|
+
try {
|
|
81
|
+
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
82
|
+
var col = _c.value;
|
|
83
|
+
var val = col.valueConverter.toDb(row[col.key]);
|
|
84
|
+
if (val === null)
|
|
85
|
+
val = NULL;
|
|
86
|
+
result[nameProvider.nameOf(col)] = val;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
90
|
+
finally {
|
|
91
|
+
try {
|
|
92
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
93
|
+
}
|
|
94
|
+
finally { if (e_2) throw e_2.error; }
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
143
97
|
};
|
|
144
98
|
MongoEntityDataProvider.prototype.count = function (where) {
|
|
145
99
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
146
|
-
var x, w;
|
|
147
|
-
return tslib_1.__generator(this, function (
|
|
148
|
-
switch (
|
|
149
|
-
case 0:
|
|
150
|
-
|
|
100
|
+
var _a, collection, e, x, w;
|
|
101
|
+
return tslib_1.__generator(this, function (_b) {
|
|
102
|
+
switch (_b.label) {
|
|
103
|
+
case 0: return [4 /*yield*/, this.collection()];
|
|
104
|
+
case 1:
|
|
105
|
+
_a = _b.sent(), collection = _a.collection, e = _a.e;
|
|
106
|
+
x = new FilterConsumerBridgeToMongo(e);
|
|
151
107
|
where.__applyToConsumer(x);
|
|
152
108
|
return [4 /*yield*/, x.resolveWhere()];
|
|
153
|
-
case
|
|
154
|
-
w =
|
|
155
|
-
return [4 /*yield*/,
|
|
156
|
-
case
|
|
157
|
-
case 3: return [2 /*return*/, _a.sent()];
|
|
109
|
+
case 2:
|
|
110
|
+
w = _b.sent();
|
|
111
|
+
return [4 /*yield*/, collection.countDocuments(w)];
|
|
112
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
158
113
|
}
|
|
159
114
|
});
|
|
160
115
|
});
|
|
161
116
|
};
|
|
162
117
|
MongoEntityDataProvider.prototype.find = function (options) {
|
|
163
118
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
164
|
-
var collection, x, where, op,
|
|
119
|
+
var _a, collection, e, x, where, op, _b, _c, s, _d, _e;
|
|
165
120
|
var e_3, _f;
|
|
166
121
|
var _this = this;
|
|
167
122
|
return tslib_1.__generator(this, function (_g) {
|
|
168
123
|
switch (_g.label) {
|
|
169
124
|
case 0: return [4 /*yield*/, this.collection()];
|
|
170
125
|
case 1:
|
|
171
|
-
|
|
172
|
-
x = new
|
|
126
|
+
_a = _g.sent(), collection = _a.collection, e = _a.e;
|
|
127
|
+
x = new FilterConsumerBridgeToMongo(e);
|
|
173
128
|
if (options === null || options === void 0 ? void 0 : options.where)
|
|
174
129
|
options.where.__applyToConsumer(x);
|
|
175
130
|
return [4 /*yield*/, x.resolveWhere()];
|
|
@@ -182,61 +137,47 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
182
137
|
op.skip = (options.page - 1) * options.limit;
|
|
183
138
|
}
|
|
184
139
|
}
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
case 6:
|
|
201
|
-
_b = _a.next();
|
|
202
|
-
return [3 /*break*/, 4];
|
|
203
|
-
case 7: return [3 /*break*/, 10];
|
|
204
|
-
case 8:
|
|
205
|
-
e_3_1 = _g.sent();
|
|
206
|
-
e_3 = { error: e_3_1 };
|
|
207
|
-
return [3 /*break*/, 10];
|
|
208
|
-
case 9:
|
|
209
|
-
try {
|
|
210
|
-
if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
|
|
140
|
+
if (options.orderBy) {
|
|
141
|
+
op.sort = {};
|
|
142
|
+
try {
|
|
143
|
+
for (_b = tslib_1.__values(options.orderBy.Segments), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
144
|
+
s = _c.value;
|
|
145
|
+
op.sort[e.nameOf(s.field)] = s.isDescending ? -1 : 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
149
|
+
finally {
|
|
150
|
+
try {
|
|
151
|
+
if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
|
|
152
|
+
}
|
|
153
|
+
finally { if (e_3) throw e_3.error; }
|
|
154
|
+
}
|
|
211
155
|
}
|
|
212
|
-
finally { if (e_3) throw e_3.error; }
|
|
213
|
-
return [7 /*endfinally*/];
|
|
214
|
-
case 10:
|
|
215
156
|
_e = (_d = Promise).all;
|
|
216
|
-
return [4 /*yield*/, collection.find(where, op).map(function (x) { return _this.translateFromJson(x); }).toArray()];
|
|
217
|
-
case
|
|
218
|
-
case
|
|
157
|
+
return [4 /*yield*/, collection.find(where, op).map(function (x) { return _this.translateFromJson(x, e); }).toArray()];
|
|
158
|
+
case 3: return [4 /*yield*/, _e.apply(_d, [_g.sent()])];
|
|
159
|
+
case 4: return [2 /*return*/, _g.sent()];
|
|
219
160
|
}
|
|
220
161
|
});
|
|
221
162
|
});
|
|
222
163
|
};
|
|
223
164
|
MongoEntityDataProvider.prototype.update = function (id, data) {
|
|
224
165
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
225
|
-
var collection, f, resultFilter,
|
|
226
|
-
var e_4,
|
|
227
|
-
return tslib_1.__generator(this, function (
|
|
228
|
-
switch (
|
|
166
|
+
var _a, collection, e, f, resultFilter, _b, _c, x, newR, keys, _d, _e, f_1, r, _f, _g;
|
|
167
|
+
var e_4, _h, e_5, _j;
|
|
168
|
+
return tslib_1.__generator(this, function (_k) {
|
|
169
|
+
switch (_k.label) {
|
|
229
170
|
case 0: return [4 /*yield*/, this.collection()];
|
|
230
171
|
case 1:
|
|
231
|
-
|
|
232
|
-
f = new
|
|
172
|
+
_a = _k.sent(), collection = _a.collection, e = _a.e;
|
|
173
|
+
f = new FilterConsumerBridgeToMongo(e);
|
|
233
174
|
_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
234
175
|
resultFilter = this.entity.idMetadata.getIdFilter(id);
|
|
235
176
|
if (data.id != undefined)
|
|
236
177
|
resultFilter = this.entity.idMetadata.getIdFilter(data.id);
|
|
237
178
|
try {
|
|
238
|
-
for (
|
|
239
|
-
x =
|
|
179
|
+
for (_b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
180
|
+
x = _c.value;
|
|
240
181
|
if (x instanceof _1.CompoundIdField) {
|
|
241
182
|
resultFilter = x.resultIdFilter(id, data);
|
|
242
183
|
}
|
|
@@ -245,15 +186,15 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
245
186
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
246
187
|
finally {
|
|
247
188
|
try {
|
|
248
|
-
if (
|
|
189
|
+
if (_c && !_c.done && (_h = _b.return)) _h.call(_b);
|
|
249
190
|
}
|
|
250
191
|
finally { if (e_4) throw e_4.error; }
|
|
251
192
|
}
|
|
252
193
|
newR = {};
|
|
253
194
|
keys = Object.keys(data);
|
|
254
195
|
try {
|
|
255
|
-
for (
|
|
256
|
-
f_1 =
|
|
196
|
+
for (_d = tslib_1.__values(this.entity.fields), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
197
|
+
f_1 = _e.value;
|
|
257
198
|
if (!f_1.dbReadOnly && !f_1.isServerExpression && !(f_1 == this.entity.idMetadata.field && this.entity.options.dbAutoIncrementId)) {
|
|
258
199
|
if (keys.includes(f_1.key)) {
|
|
259
200
|
newR[f_1.key] = f_1.valueConverter.toJson(data[f_1.key]);
|
|
@@ -264,17 +205,17 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
264
205
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
265
206
|
finally {
|
|
266
207
|
try {
|
|
267
|
-
if (
|
|
208
|
+
if (_e && !_e.done && (_j = _d.return)) _j.call(_d);
|
|
268
209
|
}
|
|
269
210
|
finally { if (e_5) throw e_5.error; }
|
|
270
211
|
}
|
|
271
|
-
|
|
212
|
+
_g = (_f = collection).updateOne;
|
|
272
213
|
return [4 /*yield*/, f.resolveWhere()];
|
|
273
|
-
case 2: return [4 /*yield*/,
|
|
214
|
+
case 2: return [4 /*yield*/, _g.apply(_f, [_k.sent(), {
|
|
274
215
|
$set: newR
|
|
275
216
|
}])];
|
|
276
217
|
case 3:
|
|
277
|
-
r =
|
|
218
|
+
r = _k.sent();
|
|
278
219
|
return [2 /*return*/, this.find({ where: _1.Filter.fromEntityFilter(this.entity, resultFilter) }).then(function (y) { return y[0]; })];
|
|
279
220
|
}
|
|
280
221
|
});
|
|
@@ -282,18 +223,18 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
282
223
|
};
|
|
283
224
|
MongoEntityDataProvider.prototype.delete = function (id) {
|
|
284
225
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
285
|
-
var f,
|
|
286
|
-
return tslib_1.__generator(this, function (
|
|
287
|
-
switch (
|
|
288
|
-
case 0:
|
|
289
|
-
f = new FilterConsumerBridgeToKnexMongo();
|
|
290
|
-
_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
291
|
-
return [4 /*yield*/, this.collection()];
|
|
226
|
+
var _a, e, collection, f, _b, _c;
|
|
227
|
+
return tslib_1.__generator(this, function (_d) {
|
|
228
|
+
switch (_d.label) {
|
|
229
|
+
case 0: return [4 /*yield*/, this.collection()];
|
|
292
230
|
case 1:
|
|
293
|
-
|
|
231
|
+
_a = _d.sent(), e = _a.e, collection = _a.collection;
|
|
232
|
+
f = new FilterConsumerBridgeToMongo(e);
|
|
233
|
+
_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
234
|
+
_c = (_b = collection).deleteOne;
|
|
294
235
|
return [4 /*yield*/, f.resolveWhere()];
|
|
295
236
|
case 2:
|
|
296
|
-
|
|
237
|
+
_c.apply(_b, [_d.sent()]);
|
|
297
238
|
return [2 /*return*/];
|
|
298
239
|
}
|
|
299
240
|
});
|
|
@@ -301,47 +242,49 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
301
242
|
};
|
|
302
243
|
MongoEntityDataProvider.prototype.insert = function (data) {
|
|
303
244
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
304
|
-
var collection,
|
|
305
|
-
return tslib_1.__generator(this, function (
|
|
306
|
-
switch (
|
|
245
|
+
var _a, collection, e, r, _b, _c, _d;
|
|
246
|
+
return tslib_1.__generator(this, function (_e) {
|
|
247
|
+
switch (_e.label) {
|
|
307
248
|
case 0: return [4 /*yield*/, this.collection()];
|
|
308
249
|
case 1:
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return [4 /*yield*/, this.translateToJson(data)];
|
|
312
|
-
case 2: return [4 /*yield*/,
|
|
250
|
+
_a = _e.sent(), collection = _a.collection, e = _a.e;
|
|
251
|
+
_c = (_b = collection).insertOne;
|
|
252
|
+
return [4 /*yield*/, this.translateToJson(data, e)];
|
|
253
|
+
case 2: return [4 /*yield*/, _c.apply(_b, [_e.sent()])];
|
|
313
254
|
case 3:
|
|
314
|
-
r =
|
|
315
|
-
|
|
255
|
+
r = _e.sent();
|
|
256
|
+
_d = this.translateFromJson;
|
|
316
257
|
return [4 /*yield*/, collection.findOne({ _id: r.insertedId })];
|
|
317
|
-
case 4: return [4 /*yield*/,
|
|
318
|
-
case 5: return [2 /*return*/,
|
|
258
|
+
case 4: return [4 /*yield*/, _d.apply(this, [_e.sent(), e])];
|
|
259
|
+
case 5: return [2 /*return*/, _e.sent()];
|
|
319
260
|
}
|
|
320
261
|
});
|
|
321
262
|
});
|
|
322
263
|
};
|
|
323
264
|
MongoEntityDataProvider.prototype.collection = function () {
|
|
324
265
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
325
|
-
var
|
|
326
|
-
return tslib_1.__generator(this, function (
|
|
327
|
-
switch (
|
|
328
|
-
case 0:
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
266
|
+
var e, collection;
|
|
267
|
+
return tslib_1.__generator(this, function (_a) {
|
|
268
|
+
switch (_a.label) {
|
|
269
|
+
case 0: return [4 /*yield*/, filter_consumer_bridge_to_sql_request_1.getDbNameProvider(this.entity)];
|
|
270
|
+
case 1:
|
|
271
|
+
e = _a.sent();
|
|
272
|
+
collection = this.db.collection(e.entityName);
|
|
273
|
+
return [2 /*return*/, { e: e, collection: collection }];
|
|
332
274
|
}
|
|
333
275
|
});
|
|
334
276
|
});
|
|
335
277
|
};
|
|
336
278
|
return MongoEntityDataProvider;
|
|
337
279
|
}());
|
|
338
|
-
var
|
|
339
|
-
function
|
|
280
|
+
var FilterConsumerBridgeToMongo = /** @class */ (function () {
|
|
281
|
+
function FilterConsumerBridgeToMongo(nameProvider) {
|
|
282
|
+
this.nameProvider = nameProvider;
|
|
340
283
|
this._addWhere = true;
|
|
341
284
|
this.promises = [];
|
|
342
285
|
this.result = [];
|
|
343
286
|
}
|
|
344
|
-
|
|
287
|
+
FilterConsumerBridgeToMongo.prototype.resolveWhere = function () {
|
|
345
288
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
346
289
|
var p, p_1, p_1_1, pr, e_6_1;
|
|
347
290
|
var e_6, _a;
|
|
@@ -388,10 +331,10 @@ var FilterConsumerBridgeToKnexMongo = /** @class */ (function () {
|
|
|
388
331
|
});
|
|
389
332
|
});
|
|
390
333
|
};
|
|
391
|
-
|
|
334
|
+
FilterConsumerBridgeToMongo.prototype.custom = function (key, customItem) {
|
|
392
335
|
throw new Error("Custom filter should be translated before it gets here");
|
|
393
336
|
};
|
|
394
|
-
|
|
337
|
+
FilterConsumerBridgeToMongo.prototype.or = function (orElements) {
|
|
395
338
|
var _this = this;
|
|
396
339
|
this.promises.push((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
397
340
|
var result, orElements_1, orElements_1_1, element, f, where, e_7_1;
|
|
@@ -408,7 +351,7 @@ var FilterConsumerBridgeToKnexMongo = /** @class */ (function () {
|
|
|
408
351
|
case 2:
|
|
409
352
|
if (!!orElements_1_1.done) return [3 /*break*/, 5];
|
|
410
353
|
element = orElements_1_1.value;
|
|
411
|
-
f = new
|
|
354
|
+
f = new FilterConsumerBridgeToMongo(this.nameProvider);
|
|
412
355
|
f._addWhere = false;
|
|
413
356
|
element.__applyToConsumer(f);
|
|
414
357
|
return [4 /*yield*/, f.resolveWhere()];
|
|
@@ -441,68 +384,58 @@ var FilterConsumerBridgeToKnexMongo = /** @class */ (function () {
|
|
|
441
384
|
});
|
|
442
385
|
}); })());
|
|
443
386
|
};
|
|
444
|
-
|
|
387
|
+
FilterConsumerBridgeToMongo.prototype.isNull = function (col) {
|
|
445
388
|
this.add(col, NULL, "$eq");
|
|
446
389
|
};
|
|
447
|
-
|
|
390
|
+
FilterConsumerBridgeToMongo.prototype.isNotNull = function (col) {
|
|
448
391
|
this.add(col, NULL, "$ne");
|
|
449
392
|
};
|
|
450
|
-
|
|
393
|
+
FilterConsumerBridgeToMongo.prototype.isIn = function (col, val) {
|
|
451
394
|
var _this = this;
|
|
452
|
-
this.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
});
|
|
461
|
-
}));
|
|
395
|
+
this.result.push(function () {
|
|
396
|
+
var _a;
|
|
397
|
+
return (_a = {},
|
|
398
|
+
_a[_this.nameProvider.nameOf(col)] = {
|
|
399
|
+
$in: val.map(function (x) { return col.valueConverter.toDb(x); })
|
|
400
|
+
},
|
|
401
|
+
_a);
|
|
402
|
+
});
|
|
462
403
|
};
|
|
463
|
-
|
|
404
|
+
FilterConsumerBridgeToMongo.prototype.isEqualTo = function (col, val) {
|
|
464
405
|
this.add(col, val, "$eq");
|
|
465
406
|
};
|
|
466
|
-
|
|
407
|
+
FilterConsumerBridgeToMongo.prototype.isDifferentFrom = function (col, val) {
|
|
467
408
|
this.add(col, val, "$ne");
|
|
468
409
|
};
|
|
469
|
-
|
|
410
|
+
FilterConsumerBridgeToMongo.prototype.isGreaterOrEqualTo = function (col, val) {
|
|
470
411
|
this.add(col, val, "$gte");
|
|
471
412
|
};
|
|
472
|
-
|
|
413
|
+
FilterConsumerBridgeToMongo.prototype.isGreaterThan = function (col, val) {
|
|
473
414
|
this.add(col, val, "$gt");
|
|
474
415
|
};
|
|
475
|
-
|
|
416
|
+
FilterConsumerBridgeToMongo.prototype.isLessOrEqualTo = function (col, val) {
|
|
476
417
|
this.add(col, val, "$lte");
|
|
477
418
|
};
|
|
478
|
-
|
|
419
|
+
FilterConsumerBridgeToMongo.prototype.isLessThan = function (col, val) {
|
|
479
420
|
this.add(col, val, "$lt");
|
|
480
421
|
};
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
throw "error";
|
|
422
|
+
FilterConsumerBridgeToMongo.prototype.containsCaseInsensitive = function (col, val) {
|
|
423
|
+
throw "containsCaseInsensitive not yet implemented";
|
|
484
424
|
// this.promises.push(col.getDbName().then(colName => {
|
|
485
425
|
// this.result.push(b => b.whereRaw(
|
|
486
426
|
// 'lower (' + colName + ") like lower ('%" + val.replace(/'/g, '\'\'') + "%')"));
|
|
487
427
|
// }));
|
|
488
|
-
this.promises.push((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
489
|
-
return tslib_1.__generator(this, function (_a) {
|
|
490
|
-
return [2 /*return*/];
|
|
491
|
-
});
|
|
492
|
-
}); })());
|
|
493
428
|
};
|
|
494
|
-
|
|
429
|
+
FilterConsumerBridgeToMongo.prototype.add = function (col, val, operator) {
|
|
495
430
|
var _this = this;
|
|
496
|
-
this.
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
});
|
|
503
|
-
}));
|
|
431
|
+
this.result.push(function () {
|
|
432
|
+
var _a, _b;
|
|
433
|
+
return (_a = {},
|
|
434
|
+
_a[_this.nameProvider.nameOf(col)] = (_b = {}, _b[operator] = isNull(val) ? val : col.valueConverter.toDb(val), _b),
|
|
435
|
+
_a);
|
|
436
|
+
});
|
|
504
437
|
};
|
|
505
|
-
|
|
438
|
+
FilterConsumerBridgeToMongo.prototype.databaseCustom = function (databaseCustom) {
|
|
506
439
|
throw "error";
|
|
507
440
|
// this.promises.push((async () => {
|
|
508
441
|
// if (databaseCustom?.buildSql) {
|
|
@@ -514,5 +447,5 @@ var FilterConsumerBridgeToKnexMongo = /** @class */ (function () {
|
|
|
514
447
|
// }
|
|
515
448
|
// })());
|
|
516
449
|
};
|
|
517
|
-
return
|
|
450
|
+
return FilterConsumerBridgeToMongo;
|
|
518
451
|
}());
|
package/server/expressBridge.js
CHANGED
|
@@ -191,7 +191,7 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
191
191
|
var apiPathWithId = spec.paths['/api/' + key + "/{id}"] = {};
|
|
192
192
|
//https://github.com/2fd/open-api.d.ts
|
|
193
193
|
apiPath.get = secure(meta.options.allowApiRead, true, {
|
|
194
|
-
description: "return an array of " + key + ". supports filter operators. For more info on filtering [see this article](https://remult.dev/
|
|
194
|
+
description: "return an array of " + key + ". supports filter operators. For more info on filtering [see this article](https://remult.dev/docs/rest-api.html#filter)",
|
|
195
195
|
parameters: tslib_1.__spread([{
|
|
196
196
|
"name": "_limit",
|
|
197
197
|
"in": "query",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dbTestWhatSignature } from "../shared-tests/db-tests-setup";
|
|
2
|
-
export declare
|
|
2
|
+
export declare const testKnexPGSqlImpl: (key: string, what: dbTestWhatSignature, focus?: boolean) => void;
|
|
3
3
|
export declare function testPostgresImplementation(key: string, what: dbTestWhatSignature, focus?: boolean): void;
|
|
4
4
|
import '../shared-tests';
|
|
5
5
|
export declare function testMongo(key: string, what: dbTestWhatSignature, focus?: boolean): void;
|