@travetto/model-query 3.1.7 → 3.1.9

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 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. Due to the nature of this operation, this is only supported on lists at the top level of the document.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-query",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "description": "Datastore abstraction for advanced query support.",
5
5
  "keywords": [
6
6
  "datastore",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@travetto/di": "^3.1.1",
31
- "@travetto/model": "^3.1.8",
32
- "@travetto/schema": "^3.1.2"
31
+ "@travetto/model": "^3.1.9",
32
+ "@travetto/schema": "^3.1.3"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@travetto/test": "^3.1.1"
@@ -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
 
@@ -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
  }