@travetto/model-query 2.2.3 → 3.0.0-rc.1
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-query",
|
|
3
3
|
"displayName": "Data Model Querying",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0-rc.1",
|
|
5
5
|
"description": "Datastore abstraction for advanced query support.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"datastore",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"directory": "module/model-query"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@travetto/di": "^
|
|
32
|
-
"@travetto/model": "^
|
|
33
|
-
"@travetto/schema": "^
|
|
31
|
+
"@travetto/di": "^3.0.0-rc.1",
|
|
32
|
+
"@travetto/model": "^3.0.0-rc.1",
|
|
33
|
+
"@travetto/schema": "^3.0.0-rc.1"
|
|
34
34
|
},
|
|
35
35
|
"docDependencies": {
|
|
36
36
|
"@travetto/model-mongo": true,
|
package/test-support/facet.ts
CHANGED
|
@@ -3,11 +3,17 @@ import * as assert from 'assert';
|
|
|
3
3
|
import { ModelCrudSupport } from '@travetto/model';
|
|
4
4
|
import { BaseModelSuite } from '@travetto/model/test-support/base';
|
|
5
5
|
import { Suite, Test } from '@travetto/test';
|
|
6
|
-
import { SchemaFakerUtil } from '@travetto/schema';
|
|
7
6
|
|
|
8
7
|
import { Person } from './types';
|
|
9
8
|
import { ModelQueryFacetSupport } from '../src/service/facet';
|
|
10
9
|
|
|
10
|
+
const pick = <T>(arr: T[]): T => arr[Math.trunc(Math.random() * arr.length)]!;
|
|
11
|
+
|
|
12
|
+
const GENDERS = ['m', 'f'] as ['m', 'f'];
|
|
13
|
+
const FNAME = ['Bob', 'Tom', 'Sarah', 'Leo', 'Alice', 'Jennifer', 'Tommy', 'George', 'Paula', 'Sam'];
|
|
14
|
+
const LNAME = ['Smith', 'Sampson', 'Thompson', 'Oscar', 'Washington', 'Jefferson', 'Samuels'];
|
|
15
|
+
const AGES = new Array(100).fill(0).map((x, i) => i + 10);
|
|
16
|
+
|
|
11
17
|
@Suite()
|
|
12
18
|
export abstract class ModelQueryFacetSuite extends BaseModelSuite<ModelQueryFacetSupport & ModelCrudSupport> {
|
|
13
19
|
|
|
@@ -15,7 +21,14 @@ export abstract class ModelQueryFacetSuite extends BaseModelSuite<ModelQueryFace
|
|
|
15
21
|
async testFacet() {
|
|
16
22
|
const people = ' '.repeat(50)
|
|
17
23
|
.split('')
|
|
18
|
-
.map(() =>
|
|
24
|
+
.map(() => Person.from({
|
|
25
|
+
age: pick(AGES),
|
|
26
|
+
gender: pick(GENDERS),
|
|
27
|
+
name: `${pick(FNAME)} ${pick(LNAME)}`,
|
|
28
|
+
address: {
|
|
29
|
+
street1: `${pick(AGES)} ${pick(LNAME)} Road`
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
19
32
|
|
|
20
33
|
const svc = await this.service;
|
|
21
34
|
const saved = await this.saveAll(Person, people);
|
|
@@ -106,6 +106,6 @@ export abstract class ModelQueryPolymorphismSuite extends BaseModelSuite<ModelQu
|
|
|
106
106
|
|
|
107
107
|
assert((await svc.facet(Worker, 'name')).length === 4);
|
|
108
108
|
const docFacet = await svc.facet(Doctor, 'specialty');
|
|
109
|
-
assert(docFacet
|
|
109
|
+
assert.deepStrictEqual(docFacet, [{ count: 2, key: 'eyes' }]);
|
|
110
110
|
}
|
|
111
111
|
}
|
package/test-support/query.ts
CHANGED
|
@@ -216,12 +216,14 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
|
|
|
216
216
|
async verifyNestedQuery() {
|
|
217
217
|
const service = await this.service;
|
|
218
218
|
|
|
219
|
+
const id = service.uuid();
|
|
220
|
+
|
|
219
221
|
await service.create(Note, Note.from({
|
|
220
|
-
id
|
|
222
|
+
id,
|
|
221
223
|
entities: [
|
|
222
224
|
{
|
|
223
225
|
label: 'hi',
|
|
224
|
-
id
|
|
226
|
+
id
|
|
225
227
|
}
|
|
226
228
|
]
|
|
227
229
|
}));
|
|
@@ -229,7 +231,7 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
|
|
|
229
231
|
const out = await service.queryCount(Note, {
|
|
230
232
|
where: {
|
|
231
233
|
entities: {
|
|
232
|
-
id
|
|
234
|
+
id
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
237
|
});
|
|
@@ -239,7 +241,7 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
|
|
|
239
241
|
const out2 = await service.query(Note, {
|
|
240
242
|
where: {
|
|
241
243
|
entities: {
|
|
242
|
-
id
|
|
244
|
+
id
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
});
|