@travetto/model-query 3.1.7 → 3.1.8
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/README.md +2 -2
- package/package.json +1 -1
- package/support/test/query.ts +72 -1
- package/support/test/types.ts +12 -0
package/README.md
CHANGED
|
@@ -158,7 +158,7 @@ One of the complexities of abstracting multiple storage mechanisms, is providing
|
|
|
158
158
|
### Array Fields
|
|
159
159
|
|
|
160
160
|
* `field: { $all: T[]] }` checks to see if the records value contains everything within `$all`
|
|
161
|
-
* `field: { $empty: boolean }` to determine if an array is missing or is of zero length.
|
|
161
|
+
* `field: { $empty: boolean }` to determine if an array is missing or is of zero length.
|
|
162
162
|
|
|
163
163
|
### String Fields
|
|
164
164
|
|
|
@@ -167,7 +167,7 @@ One of the complexities of abstracting multiple storage mechanisms, is providing
|
|
|
167
167
|
### Geo Point Fields
|
|
168
168
|
|
|
169
169
|
* `field: { $geoWithin: Point[] }` determines if the value is within the bounding region of the points
|
|
170
|
-
* `field: {$near: Point, $maxDistance: number, $unit: 'km' | 'm' | 'mi' | 'ft' }` searches at a point, and looks out radially
|
|
170
|
+
* `field: { $near: Point, $maxDistance: number, $unit: 'km' | 'm' | 'mi' | 'ft' }` searches at a point, and looks out radially
|
|
171
171
|
|
|
172
172
|
### Groupings
|
|
173
173
|
|
package/package.json
CHANGED
package/support/test/query.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseModelSuite } from '@travetto/model/support/test/base';
|
|
|
5
5
|
import { ModelCrudSupport } from '@travetto/model/src/service/crud';
|
|
6
6
|
import { TimeUtil } from '@travetto/base';
|
|
7
7
|
|
|
8
|
-
import { Aged, Location, Names, Note, Person, SimpleList, WithNestedLists } from './types';
|
|
8
|
+
import { Aged, Location, Names, Note, Person, SimpleList, WithNestedLists, WithNestedNestedLists } from './types';
|
|
9
9
|
|
|
10
10
|
import { ModelQuerySupport } from '../../src/service/query';
|
|
11
11
|
|
|
@@ -368,5 +368,76 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
|
|
|
368
368
|
|
|
369
369
|
assert(total === 1);
|
|
370
370
|
}
|
|
371
|
+
|
|
372
|
+
@Test()
|
|
373
|
+
async verifyNestedArrayEmptyVsNot() {
|
|
374
|
+
const service = await this.service;
|
|
375
|
+
await service.create(WithNestedNestedLists, {
|
|
376
|
+
tags: ['a', 'b']
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
await service.create(WithNestedNestedLists, {
|
|
380
|
+
sub: { names: ['c', 'd'] },
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
await service.create(WithNestedNestedLists, {
|
|
384
|
+
sub: { names: ['c', 'd'] },
|
|
385
|
+
tags: ['e', 'f']
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
await service.create(WithNestedNestedLists, {
|
|
389
|
+
sub: { names: ['g', 'h'] },
|
|
390
|
+
tags: []
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
await service.create(WithNestedNestedLists, {
|
|
394
|
+
sub: {},
|
|
395
|
+
tags: []
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
let total = await service.queryCount(WithNestedNestedLists, {
|
|
399
|
+
where: {
|
|
400
|
+
sub: { names: { $empty: false } }
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
assert(total === 3);
|
|
404
|
+
total = await service.queryCount(WithNestedNestedLists, {
|
|
405
|
+
where: {
|
|
406
|
+
sub: { names: { $empty: true } }
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
assert(total === 2);
|
|
410
|
+
|
|
411
|
+
total = await service.queryCount(WithNestedNestedLists, {
|
|
412
|
+
where: {
|
|
413
|
+
tags: { $empty: true }
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
assert(total === 3);
|
|
417
|
+
|
|
418
|
+
total = await service.queryCount(WithNestedNestedLists, {
|
|
419
|
+
where: {
|
|
420
|
+
tags: { $empty: false }
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
assert(total === 2);
|
|
424
|
+
|
|
425
|
+
total = await service.queryCount(WithNestedNestedLists, {
|
|
426
|
+
where: {
|
|
427
|
+
tags: { $empty: true },
|
|
428
|
+
sub: { names: { $empty: true } }
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
assert(total === 1);
|
|
432
|
+
|
|
433
|
+
total = await service.queryCount(WithNestedNestedLists, {
|
|
434
|
+
where: {
|
|
435
|
+
tags: { $empty: false },
|
|
436
|
+
sub: { names: { $empty: false } }
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
assert(total === 1);
|
|
441
|
+
}
|
|
371
442
|
}
|
|
372
443
|
|
package/support/test/types.ts
CHANGED
|
@@ -81,4 +81,16 @@ export class WithNestedLists {
|
|
|
81
81
|
id: string;
|
|
82
82
|
tags?: string[] = [];
|
|
83
83
|
names?: string[] = [];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Schema()
|
|
87
|
+
class NamedSubNested {
|
|
88
|
+
names?: string[] = [];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@Model()
|
|
92
|
+
export class WithNestedNestedLists {
|
|
93
|
+
id: string;
|
|
94
|
+
tags?: string[] = [];
|
|
95
|
+
sub?: NamedSubNested;
|
|
84
96
|
}
|