@travetto/model-query 5.0.15 → 5.0.17

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-query",
3
- "version": "5.0.15",
3
+ "version": "5.0.17",
4
4
  "description": "Datastore abstraction for advanced query support.",
5
5
  "keywords": [
6
6
  "datastore",
@@ -22,16 +22,16 @@
22
22
  ],
23
23
  "main": "__index__.ts",
24
24
  "repository": {
25
- "url": "https://github.com/travetto/travetto.git",
25
+ "url": "git+https://github.com/travetto/travetto.git",
26
26
  "directory": "module/model-query"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/di": "^5.0.14",
30
- "@travetto/model": "^5.0.15",
31
- "@travetto/schema": "^5.0.14"
29
+ "@travetto/di": "^5.0.16",
30
+ "@travetto/model": "^5.0.17",
31
+ "@travetto/schema": "^5.0.16"
32
32
  },
33
33
  "peerDependencies": {
34
- "@travetto/test": "^5.0.16"
34
+ "@travetto/test": "^5.0.18"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@travetto/test": {
package/src/verifier.ts CHANGED
@@ -5,7 +5,6 @@ import { ModelQuery, Query, PageableModelQuery } from './model/query';
5
5
 
6
6
  import { TypeUtil } from './internal/util/types';
7
7
 
8
-
9
8
  type SimpleType = keyof typeof TypeUtil.OPERATORS;
10
9
 
11
10
  interface State {
@@ -37,7 +37,6 @@ export abstract class ModelQueryCrudSuite extends BaseModelSuite<ModelQueryCrudS
37
37
  NotFoundError
38
38
  );
39
39
 
40
-
41
40
  const todo2 = await svc.create(Todo, Todo.from({ text: 'bob2' }));
42
41
 
43
42
  const result = await svc.updateByQuery(Todo, Todo.from({
@@ -88,7 +87,6 @@ export abstract class ModelQueryCrudSuite extends BaseModelSuite<ModelQueryCrudS
88
87
  }
89
88
  }
90
89
 
91
-
92
90
  @Test()
93
91
  async testDeleteByQuery() {
94
92
  const svc = await this.service;
@@ -15,6 +15,36 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
15
15
 
16
16
  supportsGeo = true;
17
17
 
18
+ @Test()
19
+ async testIds() {
20
+ const svc = await this.service;
21
+
22
+ const people = [1, 2, 3, 8].map(x => Person.from({
23
+ id: svc.idSource.create(),
24
+ name: 'Bob Omber',
25
+ age: 20 + x,
26
+ gender: 'm',
27
+ address: {
28
+ street1: 'a',
29
+ ...(x === 1 ? { street2: 'b' } : {})
30
+ }
31
+ }));
32
+
33
+ await this.saveAll(Person, people);
34
+
35
+ const one = await svc.queryOne(Person, { where: { id: people[0].id } });
36
+ assert(one.id === people[0].id);
37
+
38
+ const one2 = await svc.queryOne(Person, { where: { id: { $eq: people[0].id } } });
39
+ assert(one2.id === people[0].id);
40
+
41
+ const none = await svc.queryCount(Person, { where: { id: { $ne: people[0].id } } });
42
+ assert(none === 3);
43
+
44
+ const noneids = await svc.query(Person, { where: { id: { $ne: people[0].id } } });
45
+ assert(noneids.every(x => x.id !== people[0].id));
46
+ }
47
+
18
48
  @Test('verify word boundary')
19
49
  async testWordBoundary() {
20
50
  const service = await this.service;
@@ -38,7 +68,6 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
38
68
  assert(results3.length === 0);
39
69
  }
40
70
 
41
-
42
71
  @Test('verify query one behavior')
43
72
  async testQueryOne() {
44
73
  const service = await this.service;
@@ -62,11 +91,11 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
62
91
  @Test('Verify array $in queries work properly')
63
92
  async testArrayContains() {
64
93
  const svc = await this.service;
65
- await svc.create(SimpleList, SimpleList.from({
94
+ const first = await svc.create(SimpleList, SimpleList.from({
66
95
  names: ['a', 'b', 'c']
67
96
  }));
68
97
 
69
- await svc.create(SimpleList, SimpleList.from({
98
+ const second = await svc.create(SimpleList, SimpleList.from({
70
99
  names: ['b', 'c', 'd']
71
100
  }));
72
101
 
@@ -105,6 +134,24 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
105
134
  }
106
135
  });
107
136
  assert(none.length === 0);
137
+
138
+ const ids = await svc.query(SimpleList, {
139
+ where: {
140
+ id: {
141
+ $in: [first.id, second.id]
142
+ }
143
+ }
144
+ });
145
+ assert(ids.length === 2);
146
+
147
+ const idNin = await svc.query(SimpleList, {
148
+ where: {
149
+ id: {
150
+ $nin: ['a', 'b']
151
+ }
152
+ }
153
+ });
154
+ assert(idNin.length === 2);
108
155
  }
109
156
 
110
157
  @Test('verify all operators')
@@ -186,7 +233,6 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
186
233
  assert(all[0].age >= all[1].age);
187
234
  }
188
235
 
189
-
190
236
  @Test('Test within')
191
237
  async testWithin() {
192
238
  if (!this.supportsGeo) {
@@ -234,7 +280,6 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
234
280
  assert(rad.length > 0);
235
281
  }
236
282
 
237
-
238
283
  @Test()
239
284
  async verifyNestedQuery() {
240
285
  const service = await this.service;
@@ -288,7 +333,6 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
288
333
  });
289
334
  assert(simple === 5);
290
335
 
291
-
292
336
  const simple2 = await service.queryCount(Aged, {
293
337
  where: {
294
338
  createdAt: {
@@ -298,7 +342,6 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
298
342
  });
299
343
  assert(simple2 === 6);
300
344
 
301
-
302
345
  const simple3 = await service.queryCount(Aged, {
303
346
  where: {
304
347
  createdAt: {