remult 0.11.2 → 0.11.3
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
CHANGED
package/remult-knex/index.js
CHANGED
|
@@ -366,11 +366,12 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
366
366
|
var _this = this;
|
|
367
367
|
var statement = '';
|
|
368
368
|
this.promises.push((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
369
|
-
var _loop_1, this_1, orElements_1, orElements_1_1, element, e_5_1;
|
|
369
|
+
var result, _loop_1, this_1, orElements_1, orElements_1_1, element, e_5_1;
|
|
370
370
|
var e_5, _a;
|
|
371
371
|
return tslib_1.__generator(this, function (_b) {
|
|
372
372
|
switch (_b.label) {
|
|
373
373
|
case 0:
|
|
374
|
+
result = [];
|
|
374
375
|
_loop_1 = function (element) {
|
|
375
376
|
var f, where;
|
|
376
377
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -383,7 +384,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
383
384
|
case 1:
|
|
384
385
|
where = _a.sent();
|
|
385
386
|
if (where.length > 0) {
|
|
386
|
-
|
|
387
|
+
result.push(function (b) {
|
|
387
388
|
b.orWhere(function (b) {
|
|
388
389
|
where.forEach(function (x) { return x(b); });
|
|
389
390
|
});
|
|
@@ -420,7 +421,11 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
420
421
|
}
|
|
421
422
|
finally { if (e_5) throw e_5.error; }
|
|
422
423
|
return [7 /*endfinally*/];
|
|
423
|
-
case 8:
|
|
424
|
+
case 8:
|
|
425
|
+
if (result.length > 0) {
|
|
426
|
+
this.result.push(function (b) { return b.where(function (x) { return result.find(function (y) { return y(x); }); }); });
|
|
427
|
+
}
|
|
428
|
+
return [2 /*return*/];
|
|
424
429
|
}
|
|
425
430
|
});
|
|
426
431
|
}); })());
|
|
@@ -1210,6 +1210,67 @@ db_tests_setup_1.testAll("Paging", function (_a) {
|
|
|
1210
1210
|
});
|
|
1211
1211
|
});
|
|
1212
1212
|
}, false);
|
|
1213
|
+
db_tests_setup_1.testAll("filter", function (_a) {
|
|
1214
|
+
var createEntity = _a.createEntity;
|
|
1215
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1216
|
+
var s, _b;
|
|
1217
|
+
return tslib_1.__generator(this, function (_c) {
|
|
1218
|
+
switch (_c.label) {
|
|
1219
|
+
case 0: return [4 /*yield*/, createEntity(testFilter)];
|
|
1220
|
+
case 1:
|
|
1221
|
+
s = _c.sent();
|
|
1222
|
+
return [4 /*yield*/, s.insert({ id: 1, a: 'a', b: 'b', c: 'c' })];
|
|
1223
|
+
case 2:
|
|
1224
|
+
_c.sent();
|
|
1225
|
+
_b = expect;
|
|
1226
|
+
return [4 /*yield*/, s.count({
|
|
1227
|
+
a: 'z',
|
|
1228
|
+
$and: [testFilter.search('')]
|
|
1229
|
+
})];
|
|
1230
|
+
case 3:
|
|
1231
|
+
_b.apply(void 0, [_c.sent()]).toBe(0);
|
|
1232
|
+
return [2 /*return*/];
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
});
|
|
1236
|
+
}, false);
|
|
1237
|
+
var testFilter = /** @class */ (function () {
|
|
1238
|
+
function testFilter() {
|
|
1239
|
+
this.id = 0;
|
|
1240
|
+
this.a = '';
|
|
1241
|
+
this.b = '';
|
|
1242
|
+
this.c = '';
|
|
1243
|
+
}
|
|
1244
|
+
testFilter.search = filter_interfaces_1.Filter.createCustom(function (remult, str) { return ({
|
|
1245
|
+
$and: [{
|
|
1246
|
+
$or: [
|
|
1247
|
+
{ a: 'a' },
|
|
1248
|
+
{ b: 'a' },
|
|
1249
|
+
{ c: 'a' }
|
|
1250
|
+
]
|
|
1251
|
+
}]
|
|
1252
|
+
}); });
|
|
1253
|
+
tslib_1.__decorate([
|
|
1254
|
+
remult3_1.Field(),
|
|
1255
|
+
tslib_1.__metadata("design:type", Number)
|
|
1256
|
+
], testFilter.prototype, "id", void 0);
|
|
1257
|
+
tslib_1.__decorate([
|
|
1258
|
+
remult3_1.Field(),
|
|
1259
|
+
tslib_1.__metadata("design:type", String)
|
|
1260
|
+
], testFilter.prototype, "a", void 0);
|
|
1261
|
+
tslib_1.__decorate([
|
|
1262
|
+
remult3_1.Field(),
|
|
1263
|
+
tslib_1.__metadata("design:type", String)
|
|
1264
|
+
], testFilter.prototype, "b", void 0);
|
|
1265
|
+
tslib_1.__decorate([
|
|
1266
|
+
remult3_1.Field(),
|
|
1267
|
+
tslib_1.__metadata("design:type", String)
|
|
1268
|
+
], testFilter.prototype, "c", void 0);
|
|
1269
|
+
testFilter = tslib_1.__decorate([
|
|
1270
|
+
remult3_1.Entity("testfilter", { allowApiCrud: true })
|
|
1271
|
+
], testFilter);
|
|
1272
|
+
return testFilter;
|
|
1273
|
+
}());
|
|
1213
1274
|
var testStringWithNull = /** @class */ (function (_super) {
|
|
1214
1275
|
tslib_1.__extends(testStringWithNull, _super);
|
|
1215
1276
|
function testStringWithNull() {
|