@nymphjs/nymph 1.0.0-beta.5 → 1.0.0-beta.51
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/CHANGELOG.md +235 -0
- package/README.md +15 -15
- package/dist/Entity.d.ts +24 -3
- package/dist/Entity.js +194 -86
- package/dist/Entity.js.map +1 -1
- package/dist/Entity.test.js +34 -17
- package/dist/Entity.test.js.map +1 -1
- package/dist/Entity.types.d.ts +3 -1
- package/dist/Nymph.d.ts +22 -7
- package/dist/Nymph.js +214 -68
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +18 -5
- package/dist/Nymph.types.js +1 -1
- package/dist/Nymph.types.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +1 -22
- package/dist/driver/NymphDriver.js +85 -105
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/testArtifacts.js +208 -159
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/errors/InvalidStateError.d.ts +3 -0
- package/dist/errors/InvalidStateError.js +11 -0
- package/dist/errors/InvalidStateError.js.map +1 -0
- package/dist/errors/QueryFailedError.js.map +1 -1
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/testArtifacts.d.ts +10 -3
- package/dist/testArtifacts.js +20 -11
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.d.ts +10 -7
- package/dist/testMocks.js +22 -10
- package/dist/testMocks.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +11 -5
- package/dist/utils.js.map +1 -1
- package/package.json +15 -15
- package/src/Entity.test.ts +33 -11
- package/src/Entity.ts +303 -127
- package/src/Entity.types.ts +13 -1
- package/src/Nymph.ts +392 -88
- package/src/Nymph.types.ts +95 -24
- package/src/driver/NymphDriver.ts +203 -282
- package/src/driver/testArtifacts.ts +238 -157
- package/src/errors/InvalidStateError.ts +6 -0
- package/src/errors/index.ts +2 -0
- package/src/nymphJoiProps.ts +2 -2
- package/src/testArtifacts.ts +28 -10
- package/src/testMocks.ts +42 -25
- package/src/utils.ts +22 -8
- package/typedoc.json +4 -0
|
@@ -3,16 +3,22 @@ import strtotime from 'locutus/php/datetime/strtotime';
|
|
|
3
3
|
import { guid } from '@nymphjs/guid';
|
|
4
4
|
|
|
5
5
|
import type Nymph from '../Nymph';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
TestBModel as TestBModelClass,
|
|
8
|
+
TestModel as TestModelClass,
|
|
9
|
+
TestModelData,
|
|
10
|
+
TestEmptyModel as TestEmptyModelClass,
|
|
11
|
+
} from '../testArtifacts';
|
|
7
12
|
|
|
8
13
|
export function QueriesTest(
|
|
9
14
|
nymph: Nymph,
|
|
10
|
-
it: (name: string, fn: () => void) => void
|
|
15
|
+
it: (name: string, fn: () => void) => void,
|
|
11
16
|
) {
|
|
12
|
-
nymph.addEntityClass(
|
|
13
|
-
nymph.addEntityClass(
|
|
17
|
+
const TestModel = nymph.addEntityClass(TestModelClass);
|
|
18
|
+
const TestBModel = nymph.addEntityClass(TestBModelClass);
|
|
19
|
+
const TestEmptyModel = nymph.addEntityClass(TestEmptyModelClass);
|
|
14
20
|
|
|
15
|
-
let testEntity:
|
|
21
|
+
let testEntity: TestModelClass & TestModelData;
|
|
16
22
|
let testGuid: string;
|
|
17
23
|
let refGuid: string;
|
|
18
24
|
let createdMultiple = false;
|
|
@@ -35,7 +41,10 @@ export function QueriesTest(
|
|
|
35
41
|
|
|
36
42
|
This one's email address is nice_hat-wednesday+newyork@im-a-hat.hat.
|
|
37
43
|
This one's phone number is (555) 555-1818.
|
|
38
|
-
This one's zip code is 92064
|
|
44
|
+
This one's zip code is 92064.
|
|
45
|
+
This one's favorite emojis are 🔥❤️😊😂⭐🤔
|
|
46
|
+
|
|
47
|
+
These hats are absolutely fantastic.`;
|
|
39
48
|
testEntity.number = 30;
|
|
40
49
|
testEntity.numberString = '30';
|
|
41
50
|
testEntity.timestamp = Date.now();
|
|
@@ -43,7 +52,7 @@ This one's zip code is 92064.`;
|
|
|
43
52
|
expect(testEntity.guid).not.toBeNull();
|
|
44
53
|
testGuid = testEntity.guid as string;
|
|
45
54
|
|
|
46
|
-
const entityReferenceTest:
|
|
55
|
+
const entityReferenceTest: TestModelClass & TestModelData = new TestModel();
|
|
47
56
|
entityReferenceTest.string = 'wrong';
|
|
48
57
|
entityReferenceTest.timestamp = strtotime('-2 days') * 1000;
|
|
49
58
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
@@ -55,19 +64,11 @@ This one's zip code is 92064.`;
|
|
|
55
64
|
entityReferenceTest.test = 'good';
|
|
56
65
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
57
66
|
|
|
58
|
-
// Test synchronous getEntity.
|
|
59
|
-
testEntity = nymph.driver.getEntitySync(
|
|
60
|
-
{ class: TestModel },
|
|
61
|
-
testGuid
|
|
62
|
-
) as TestModel & TestModelData;
|
|
63
|
-
expect(testEntity).toBeInstanceOf(TestModel);
|
|
64
|
-
expect(testEntity.guid).toEqual(testGuid);
|
|
65
|
-
|
|
66
67
|
// Test asynchronous getEntity.
|
|
67
68
|
testEntity = (await nymph.getEntity(
|
|
68
69
|
{ class: TestModel },
|
|
69
|
-
testGuid
|
|
70
|
-
)) as
|
|
70
|
+
testGuid,
|
|
71
|
+
)) as TestModelClass & TestModelData;
|
|
71
72
|
expect(testEntity).toBeInstanceOf(TestModel);
|
|
72
73
|
expect(testEntity.guid).toEqual(testGuid);
|
|
73
74
|
}
|
|
@@ -80,6 +81,8 @@ This one's zip code is 92064.`;
|
|
|
80
81
|
for (let i = 0; i < 100; i++) {
|
|
81
82
|
const testEntity = await TestModel.factory();
|
|
82
83
|
testEntity.name = `Multi Test ${i}`;
|
|
84
|
+
// Reverse the number for sort testing.
|
|
85
|
+
testEntity.number = 100 - i;
|
|
83
86
|
testEntity.$removeTag('test');
|
|
84
87
|
testEntity.$addTag('multiTest');
|
|
85
88
|
expect(await testEntity.$save()).toEqual(true);
|
|
@@ -104,6 +107,13 @@ This one's zip code is 92064.`;
|
|
|
104
107
|
await createTestEntities();
|
|
105
108
|
});
|
|
106
109
|
|
|
110
|
+
it("doesn't create empty entity", async () => {
|
|
111
|
+
const testEntity = await TestEmptyModel.factory();
|
|
112
|
+
|
|
113
|
+
expect(await testEntity.$save()).toBeFalsy();
|
|
114
|
+
expect(testEntity.guid).toBeNull();
|
|
115
|
+
});
|
|
116
|
+
|
|
107
117
|
it('update mdate on save', async () => {
|
|
108
118
|
await createTestEntities();
|
|
109
119
|
|
|
@@ -146,7 +156,7 @@ This one's zip code is 92064.`;
|
|
|
146
156
|
|
|
147
157
|
if (!(await transaction.inTransaction())) {
|
|
148
158
|
console.log(
|
|
149
|
-
'This Nymph driver or database seems to not support transactions. Skipping transaction tests.'
|
|
159
|
+
'This Nymph driver or database seems to not support transactions. Skipping transaction tests.',
|
|
150
160
|
);
|
|
151
161
|
await transaction.rollback('test');
|
|
152
162
|
return;
|
|
@@ -177,7 +187,7 @@ This one's zip code is 92064.`;
|
|
|
177
187
|
expect(await testEntity.$delete()).toEqual(true);
|
|
178
188
|
const resultEntity = await transaction.getEntity(
|
|
179
189
|
{ class: TestModel },
|
|
180
|
-
testGuid
|
|
190
|
+
testGuid,
|
|
181
191
|
);
|
|
182
192
|
expect(resultEntity).toBeNull();
|
|
183
193
|
|
|
@@ -190,13 +200,13 @@ This one's zip code is 92064.`;
|
|
|
190
200
|
// Verify it's back.
|
|
191
201
|
testEntity = (await transaction.getEntity(
|
|
192
202
|
{ class: TestModel },
|
|
193
|
-
testGuid
|
|
194
|
-
)) as
|
|
203
|
+
testGuid,
|
|
204
|
+
)) as TestModelClass & TestModelData;
|
|
195
205
|
|
|
196
206
|
expect(testEntity.guid).toEqual(testGuid);
|
|
197
207
|
|
|
198
|
-
// Start a new transaction.
|
|
199
|
-
transaction = await nymph.startTransaction('test');
|
|
208
|
+
// Start a new transaction with a dot in the name.
|
|
209
|
+
transaction = await nymph.startTransaction('test.1');
|
|
200
210
|
testEntity.$nymph = transaction;
|
|
201
211
|
|
|
202
212
|
// Verify in a transaction.
|
|
@@ -207,7 +217,7 @@ This one's zip code is 92064.`;
|
|
|
207
217
|
expect(await testEntity.$save()).toEqual(true);
|
|
208
218
|
|
|
209
219
|
// Commit the transaction.
|
|
210
|
-
await transaction.commit('test');
|
|
220
|
+
await transaction.commit('test.1');
|
|
211
221
|
testEntity.$nymph = nymph;
|
|
212
222
|
|
|
213
223
|
// Verify not in a transaction.
|
|
@@ -236,7 +246,7 @@ This one's zip code is 92064.`;
|
|
|
236
246
|
limit: 1,
|
|
237
247
|
sort: 'cdate',
|
|
238
248
|
},
|
|
239
|
-
{ type: '&', tag: 'test' }
|
|
249
|
+
{ type: '&', tag: 'test' },
|
|
240
250
|
);
|
|
241
251
|
expect(resultEntities.length).toEqual(1);
|
|
242
252
|
expect(testEntity.$is(resultEntities[0])).toEqual(true);
|
|
@@ -248,7 +258,7 @@ This one's zip code is 92064.`;
|
|
|
248
258
|
// Retrieving entity by GUID and tags...
|
|
249
259
|
const resultEntity = await nymph.getEntity(
|
|
250
260
|
{ class: TestModel },
|
|
251
|
-
{ type: '&', guid: testGuid, tag: 'test' }
|
|
261
|
+
{ type: '&', guid: testGuid, tag: 'test' },
|
|
252
262
|
);
|
|
253
263
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
254
264
|
});
|
|
@@ -259,7 +269,7 @@ This one's zip code is 92064.`;
|
|
|
259
269
|
// Retrieving entity by GUID and tags...
|
|
260
270
|
const resultEntity = await nymph.getEntity(
|
|
261
271
|
{ class: TestModel },
|
|
262
|
-
{ type: '|', guid: [testGuid, guid()] }
|
|
272
|
+
{ type: '|', guid: [testGuid, guid()] },
|
|
263
273
|
);
|
|
264
274
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
265
275
|
});
|
|
@@ -270,7 +280,7 @@ This one's zip code is 92064.`;
|
|
|
270
280
|
// Retrieving entity by GUID and tags...
|
|
271
281
|
const resultEntity = await nymph.getEntity(
|
|
272
282
|
{ class: TestModel },
|
|
273
|
-
{ type: '|', guid: [guid(), guid()] }
|
|
283
|
+
{ type: '|', guid: [guid(), guid()] },
|
|
274
284
|
);
|
|
275
285
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
276
286
|
});
|
|
@@ -281,7 +291,7 @@ This one's zip code is 92064.`;
|
|
|
281
291
|
// Retrieving entity by !GUID...
|
|
282
292
|
const resultEntity = await nymph.getEntities(
|
|
283
293
|
{ class: TestModel },
|
|
284
|
-
{ type: '&', '!guid': guid(), tag: 'test' }
|
|
294
|
+
{ type: '&', '!guid': guid(), tag: 'test' },
|
|
285
295
|
);
|
|
286
296
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
287
297
|
});
|
|
@@ -292,7 +302,7 @@ This one's zip code is 92064.`;
|
|
|
292
302
|
// Retrieving entity by !tags...
|
|
293
303
|
const resultEntity = await nymph.getEntities(
|
|
294
304
|
{ class: TestModel },
|
|
295
|
-
{ type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] }
|
|
305
|
+
{ type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] },
|
|
296
306
|
);
|
|
297
307
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
298
308
|
});
|
|
@@ -303,7 +313,7 @@ This one's zip code is 92064.`;
|
|
|
303
313
|
// Testing GUID and wrong tags...
|
|
304
314
|
const resultEntity = await nymph.getEntity(
|
|
305
315
|
{ class: TestModel },
|
|
306
|
-
{ type: '&', guid: testGuid, tag: ['pickles'] }
|
|
316
|
+
{ type: '&', guid: testGuid, tag: ['pickles'] },
|
|
307
317
|
);
|
|
308
318
|
expect(resultEntity).toBeNull();
|
|
309
319
|
});
|
|
@@ -314,7 +324,7 @@ This one's zip code is 92064.`;
|
|
|
314
324
|
// Retrieving entity by tags...
|
|
315
325
|
const resultEntity = await nymph.getEntities(
|
|
316
326
|
{ class: TestModel },
|
|
317
|
-
{ type: '&', tag: 'test' }
|
|
327
|
+
{ type: '&', tag: 'test' },
|
|
318
328
|
);
|
|
319
329
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
320
330
|
});
|
|
@@ -325,7 +335,7 @@ This one's zip code is 92064.`;
|
|
|
325
335
|
// Testing wrong tags...
|
|
326
336
|
const resultEntity = await nymph.getEntities(
|
|
327
337
|
{ class: TestModel },
|
|
328
|
-
{ type: '&', tag: 'pickles' }
|
|
338
|
+
{ type: '&', tag: 'pickles' },
|
|
329
339
|
);
|
|
330
340
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
331
341
|
});
|
|
@@ -336,7 +346,7 @@ This one's zip code is 92064.`;
|
|
|
336
346
|
// Retrieving entity by tags inclusively...
|
|
337
347
|
const resultEntity = await nymph.getEntities(
|
|
338
348
|
{ class: TestModel },
|
|
339
|
-
{ type: '|', tag: ['pickles', 'test', 'barbecue'] }
|
|
349
|
+
{ type: '|', tag: ['pickles', 'test', 'barbecue'] },
|
|
340
350
|
);
|
|
341
351
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
342
352
|
});
|
|
@@ -347,7 +357,7 @@ This one's zip code is 92064.`;
|
|
|
347
357
|
// Testing wrong inclusive tags...
|
|
348
358
|
const resultEntity = await nymph.getEntities(
|
|
349
359
|
{ class: TestModel },
|
|
350
|
-
{ type: '|', tag: ['pickles', 'barbecue'] }
|
|
360
|
+
{ type: '|', tag: ['pickles', 'barbecue'] },
|
|
351
361
|
);
|
|
352
362
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
353
363
|
});
|
|
@@ -359,7 +369,7 @@ This one's zip code is 92064.`;
|
|
|
359
369
|
const resultEntity = await nymph.getEntities(
|
|
360
370
|
{ class: TestModel },
|
|
361
371
|
{ type: '&', tag: 'test' },
|
|
362
|
-
{ type: '|', tag: ['pickles', 'test', 'barbecue'] }
|
|
372
|
+
{ type: '|', tag: ['pickles', 'test', 'barbecue'] },
|
|
363
373
|
);
|
|
364
374
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
365
375
|
});
|
|
@@ -371,7 +381,7 @@ This one's zip code is 92064.`;
|
|
|
371
381
|
const resultEntity = await nymph.getEntities(
|
|
372
382
|
{ class: TestModel },
|
|
373
383
|
{ type: '&', tag: 'test' },
|
|
374
|
-
{ type: '|', tag: ['pickles', 'barbecue'] }
|
|
384
|
+
{ type: '|', tag: ['pickles', 'barbecue'] },
|
|
375
385
|
);
|
|
376
386
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
377
387
|
});
|
|
@@ -383,7 +393,7 @@ This one's zip code is 92064.`;
|
|
|
383
393
|
const resultEntity = await nymph.getEntities(
|
|
384
394
|
{ class: TestModel },
|
|
385
395
|
{ type: '&', tag: 'pickles' },
|
|
386
|
-
{ type: '|', tag: ['test', 'barbecue'] }
|
|
396
|
+
{ type: '|', tag: ['test', 'barbecue'] },
|
|
387
397
|
);
|
|
388
398
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
389
399
|
});
|
|
@@ -394,7 +404,7 @@ This one's zip code is 92064.`;
|
|
|
394
404
|
// Retrieving entity by defined...
|
|
395
405
|
const resultEntity = await nymph.getEntities(
|
|
396
406
|
{ class: TestModel },
|
|
397
|
-
{ type: '&', defined: 'string' }
|
|
407
|
+
{ type: '&', defined: 'string' },
|
|
398
408
|
);
|
|
399
409
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
400
410
|
});
|
|
@@ -405,7 +415,7 @@ This one's zip code is 92064.`;
|
|
|
405
415
|
// Retrieving entity by !defined...
|
|
406
416
|
const resultEntity = await nymph.getEntities(
|
|
407
417
|
{ class: TestModel },
|
|
408
|
-
{ type: '&', tag: 'test', '!defined': 'pickles' }
|
|
418
|
+
{ type: '&', tag: 'test', '!defined': 'pickles' },
|
|
409
419
|
);
|
|
410
420
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
411
421
|
});
|
|
@@ -417,7 +427,7 @@ This one's zip code is 92064.`;
|
|
|
417
427
|
const resultEntity = await nymph.getEntities(
|
|
418
428
|
{ class: TestModel },
|
|
419
429
|
{ type: '!&', defined: 'pickles' },
|
|
420
|
-
{ type: '&', tag: 'test' }
|
|
430
|
+
{ type: '&', tag: 'test' },
|
|
421
431
|
);
|
|
422
432
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
423
433
|
});
|
|
@@ -428,7 +438,7 @@ This one's zip code is 92064.`;
|
|
|
428
438
|
// Retrieving entity by equal...
|
|
429
439
|
const resultEntity = await nymph.getEntities(
|
|
430
440
|
{ class: TestModel },
|
|
431
|
-
{ type: '&', equal: ['string', 'test'] }
|
|
441
|
+
{ type: '&', equal: ['string', 'test'] },
|
|
432
442
|
);
|
|
433
443
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
434
444
|
});
|
|
@@ -442,7 +452,7 @@ This one's zip code is 92064.`;
|
|
|
442
452
|
// Retrieving entity by !equal...
|
|
443
453
|
const resultEntity = await nymph.getEntities(
|
|
444
454
|
{ class: TestModel },
|
|
445
|
-
{ type: '&', tag: 'test', '!equal': ['string', 'wrong'] }
|
|
455
|
+
{ type: '&', tag: 'test', '!equal': ['string', 'wrong'] },
|
|
446
456
|
);
|
|
447
457
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
448
458
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -454,7 +464,7 @@ This one's zip code is 92064.`;
|
|
|
454
464
|
// Retrieving entity by like...
|
|
455
465
|
const resultEntity = await nymph.getEntities(
|
|
456
466
|
{ class: TestModel },
|
|
457
|
-
{ type: '&', like: ['string', 't_s%'] }
|
|
467
|
+
{ type: '&', like: ['string', 't_s%'] },
|
|
458
468
|
);
|
|
459
469
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
460
470
|
});
|
|
@@ -468,7 +478,7 @@ This one's zip code is 92064.`;
|
|
|
468
478
|
// Retrieving entity by !like...
|
|
469
479
|
const resultEntity = await nymph.getEntities(
|
|
470
480
|
{ class: TestModel },
|
|
471
|
-
{ type: '&', tag: 'test', '!like': ['string', 'wr_n%'] }
|
|
481
|
+
{ type: '&', tag: 'test', '!like': ['string', 'wr_n%'] },
|
|
472
482
|
);
|
|
473
483
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
474
484
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -480,7 +490,7 @@ This one's zip code is 92064.`;
|
|
|
480
490
|
// Retrieving entity by ilike...
|
|
481
491
|
const resultEntity = await nymph.getEntities(
|
|
482
492
|
{ class: TestModel },
|
|
483
|
-
{ type: '&', ilike: ['string', 'T_s%'] }
|
|
493
|
+
{ type: '&', ilike: ['string', 'T_s%'] },
|
|
484
494
|
);
|
|
485
495
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
486
496
|
});
|
|
@@ -494,7 +504,7 @@ This one's zip code is 92064.`;
|
|
|
494
504
|
// Retrieving entity by !ilike...
|
|
495
505
|
const resultEntity = await nymph.getEntities(
|
|
496
506
|
{ class: TestModel },
|
|
497
|
-
{ type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] }
|
|
507
|
+
{ type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] },
|
|
498
508
|
);
|
|
499
509
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
500
510
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -506,7 +516,7 @@ This one's zip code is 92064.`;
|
|
|
506
516
|
// Retrieving entity by like...
|
|
507
517
|
const resultEntity = await nymph.getEntities(
|
|
508
518
|
{ class: TestModel },
|
|
509
|
-
{ type: '&', like: ['string', 'T_s%'] }
|
|
519
|
+
{ type: '&', like: ['string', 'T_s%'] },
|
|
510
520
|
);
|
|
511
521
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
512
522
|
});
|
|
@@ -517,7 +527,7 @@ This one's zip code is 92064.`;
|
|
|
517
527
|
// Retrieving entity by tags and equal...
|
|
518
528
|
const resultEntity = await nymph.getEntities(
|
|
519
529
|
{ class: TestModel },
|
|
520
|
-
{ type: '&', tag: 'test', equal: ['string', 'test'] }
|
|
530
|
+
{ type: '&', tag: 'test', equal: ['string', 'test'] },
|
|
521
531
|
);
|
|
522
532
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
523
533
|
});
|
|
@@ -528,7 +538,7 @@ This one's zip code is 92064.`;
|
|
|
528
538
|
// Testing wrong tags and right equal...
|
|
529
539
|
const resultEntity = await nymph.getEntities(
|
|
530
540
|
{ class: TestModel },
|
|
531
|
-
{ type: '&', tag: 'pickles', equal: ['string', 'test'] }
|
|
541
|
+
{ type: '&', tag: 'pickles', equal: ['string', 'test'] },
|
|
532
542
|
);
|
|
533
543
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
534
544
|
});
|
|
@@ -539,7 +549,7 @@ This one's zip code is 92064.`;
|
|
|
539
549
|
// Testing right tags and wrong equal...
|
|
540
550
|
const resultEntity = await nymph.getEntities(
|
|
541
551
|
{ class: TestModel },
|
|
542
|
-
{ type: '&', tag: 'test', equal: ['string', 'pickles'] }
|
|
552
|
+
{ type: '&', tag: 'test', equal: ['string', 'pickles'] },
|
|
543
553
|
);
|
|
544
554
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
545
555
|
});
|
|
@@ -550,7 +560,7 @@ This one's zip code is 92064.`;
|
|
|
550
560
|
// Testing wrong tags and wrong equal...
|
|
551
561
|
const resultEntity = await nymph.getEntities(
|
|
552
562
|
{ class: TestModel },
|
|
553
|
-
{ type: '&', tag: 'pickles', equal: ['string', 'pickles'] }
|
|
563
|
+
{ type: '&', tag: 'pickles', equal: ['string', 'pickles'] },
|
|
554
564
|
);
|
|
555
565
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
556
566
|
});
|
|
@@ -561,14 +571,14 @@ This one's zip code is 92064.`;
|
|
|
561
571
|
// Retrieving entity by contain...
|
|
562
572
|
let resultEntity = await nymph.getEntities(
|
|
563
573
|
{ class: TestModel },
|
|
564
|
-
{ type: '&', contain: ['array', 'values'] }
|
|
574
|
+
{ type: '&', contain: ['array', 'values'] },
|
|
565
575
|
);
|
|
566
576
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
567
577
|
|
|
568
578
|
// Retrieving entity by contain with full match...
|
|
569
579
|
resultEntity = await nymph.getEntities(
|
|
570
580
|
{ class: TestModel },
|
|
571
|
-
{ type: '&', contain: ['string', 'test'] }
|
|
581
|
+
{ type: '&', contain: ['string', 'test'] },
|
|
572
582
|
);
|
|
573
583
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
574
584
|
});
|
|
@@ -580,7 +590,7 @@ This one's zip code is 92064.`;
|
|
|
580
590
|
const resultEntity = await nymph.getEntities(
|
|
581
591
|
{ class: TestModel },
|
|
582
592
|
{ type: '&', tag: 'test' },
|
|
583
|
-
{ type: '!&', contain: ['array', 'pickles'] }
|
|
593
|
+
{ type: '!&', contain: ['array', 'pickles'] },
|
|
584
594
|
);
|
|
585
595
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
586
596
|
});
|
|
@@ -591,14 +601,14 @@ This one's zip code is 92064.`;
|
|
|
591
601
|
// Testing wrong contain...
|
|
592
602
|
let resultEntity = await nymph.getEntities(
|
|
593
603
|
{ class: TestModel },
|
|
594
|
-
{ type: '&', contain: ['array', 'pickles'] }
|
|
604
|
+
{ type: '&', contain: ['array', 'pickles'] },
|
|
595
605
|
);
|
|
596
606
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
597
607
|
|
|
598
608
|
// Testing wrong contain...
|
|
599
609
|
resultEntity = await nymph.getEntities(
|
|
600
610
|
{ class: TestModel },
|
|
601
|
-
{ type: '&', contain: ['string', 'pickles'] }
|
|
611
|
+
{ type: '&', contain: ['string', 'pickles'] },
|
|
602
612
|
);
|
|
603
613
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
604
614
|
});
|
|
@@ -609,12 +619,12 @@ This one's zip code is 92064.`;
|
|
|
609
619
|
// Retrieving entity by regex match...
|
|
610
620
|
let resultEntity = await nymph.getEntities(
|
|
611
621
|
{ class: TestModel },
|
|
612
|
-
{ type: '&', match: ['match', '.*'] } // anything
|
|
622
|
+
{ type: '&', match: ['match', '.*'] }, // anything
|
|
613
623
|
);
|
|
614
624
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
615
625
|
resultEntity = await nymph.getEntities(
|
|
616
626
|
{ class: TestModel },
|
|
617
|
-
{ type: '&', tag: 'test', match: ['match', 'Edward McCheese'] } // a substring
|
|
627
|
+
{ type: '&', tag: 'test', match: ['match', 'Edward McCheese'] }, // a substring
|
|
618
628
|
);
|
|
619
629
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
620
630
|
resultEntity = await nymph.getEntities(
|
|
@@ -626,7 +636,7 @@ This one's zip code is 92064.`;
|
|
|
626
636
|
['string', '[0-9]'],
|
|
627
637
|
['match', 'Edward McCheese'],
|
|
628
638
|
],
|
|
629
|
-
} // inclusive test
|
|
639
|
+
}, // inclusive test
|
|
630
640
|
);
|
|
631
641
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
632
642
|
resultEntity = await nymph.getEntities(
|
|
@@ -635,7 +645,7 @@ This one's zip code is 92064.`;
|
|
|
635
645
|
type: '&',
|
|
636
646
|
tag: 'test',
|
|
637
647
|
match: ['match', '[-a-zA-Z0-9+_]+@[-a-zA-Z0-9_]+.[-a-zA-Z0-9_]{2,4}'],
|
|
638
|
-
} // a simple email
|
|
648
|
+
}, // a simple email
|
|
639
649
|
);
|
|
640
650
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
641
651
|
resultEntity = await nymph.getEntities(
|
|
@@ -644,7 +654,7 @@ This one's zip code is 92064.`;
|
|
|
644
654
|
type: '&',
|
|
645
655
|
tag: 'test',
|
|
646
656
|
match: ['match', '\\([0-9]{3}\\) [0-9]{3}-[0-9]{4}'],
|
|
647
|
-
} // a phone number
|
|
657
|
+
}, // a phone number
|
|
648
658
|
);
|
|
649
659
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
650
660
|
});
|
|
@@ -655,7 +665,7 @@ This one's zip code is 92064.`;
|
|
|
655
665
|
// Retrieving entity by regex match...
|
|
656
666
|
const resultEntity = await nymph.getEntities(
|
|
657
667
|
{ class: TestModel },
|
|
658
|
-
{ type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] } // a substring
|
|
668
|
+
{ type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] }, // a substring
|
|
659
669
|
);
|
|
660
670
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
661
671
|
});
|
|
@@ -666,12 +676,12 @@ This one's zip code is 92064.`;
|
|
|
666
676
|
// Testing wrong regex match...
|
|
667
677
|
let resultEntity = await nymph.getEntities(
|
|
668
678
|
{ class: TestModel },
|
|
669
|
-
{ type: '&', match: ['match', 'Q'] }
|
|
679
|
+
{ type: '&', match: ['match', 'Q'] },
|
|
670
680
|
);
|
|
671
681
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
672
682
|
resultEntity = await nymph.getEntities(
|
|
673
683
|
{ class: TestModel },
|
|
674
|
-
{ type: '&', tag: 'pickle', match: ['match', '.*'] }
|
|
684
|
+
{ type: '&', tag: 'pickle', match: ['match', '.*'] },
|
|
675
685
|
);
|
|
676
686
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
677
687
|
resultEntity = await nymph.getEntities(
|
|
@@ -682,7 +692,7 @@ This one's zip code is 92064.`;
|
|
|
682
692
|
['string', '[0-9]'],
|
|
683
693
|
['match', ',,'],
|
|
684
694
|
],
|
|
685
|
-
}
|
|
695
|
+
},
|
|
686
696
|
);
|
|
687
697
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
688
698
|
});
|
|
@@ -693,7 +703,7 @@ This one's zip code is 92064.`;
|
|
|
693
703
|
// Retrieving entity by regex match...
|
|
694
704
|
const resultEntity = await nymph.getEntities(
|
|
695
705
|
{ class: TestModel },
|
|
696
|
-
{ type: '&', tag: 'test', match: ['match', 'edward mccheese'] } // a substring
|
|
706
|
+
{ type: '&', tag: 'test', match: ['match', 'edward mccheese'] }, // a substring
|
|
697
707
|
);
|
|
698
708
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
699
709
|
});
|
|
@@ -705,7 +715,7 @@ This one's zip code is 92064.`;
|
|
|
705
715
|
const resultEntity = await nymph.getEntities(
|
|
706
716
|
{ class: TestModel },
|
|
707
717
|
{ type: '&', tag: 'test' },
|
|
708
|
-
{ type: '|', equal: ['string', 'pickles'], match: ['string', 'test'] }
|
|
718
|
+
{ type: '|', equal: ['string', 'pickles'], match: ['string', 'test'] },
|
|
709
719
|
);
|
|
710
720
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
711
721
|
});
|
|
@@ -722,7 +732,7 @@ This one's zip code is 92064.`;
|
|
|
722
732
|
['number', 30],
|
|
723
733
|
['pickles', 100],
|
|
724
734
|
],
|
|
725
|
-
}
|
|
735
|
+
},
|
|
726
736
|
);
|
|
727
737
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
728
738
|
|
|
@@ -735,7 +745,7 @@ This one's zip code is 92064.`;
|
|
|
735
745
|
['number', 31],
|
|
736
746
|
['pickles', 100],
|
|
737
747
|
],
|
|
738
|
-
}
|
|
748
|
+
},
|
|
739
749
|
);
|
|
740
750
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
741
751
|
|
|
@@ -748,7 +758,7 @@ This one's zip code is 92064.`;
|
|
|
748
758
|
['number', 29],
|
|
749
759
|
['pickles', 100],
|
|
750
760
|
],
|
|
751
|
-
}
|
|
761
|
+
},
|
|
752
762
|
);
|
|
753
763
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
754
764
|
|
|
@@ -761,7 +771,7 @@ This one's zip code is 92064.`;
|
|
|
761
771
|
['numberString', 30],
|
|
762
772
|
['pickles', 100],
|
|
763
773
|
],
|
|
764
|
-
}
|
|
774
|
+
},
|
|
765
775
|
);
|
|
766
776
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
767
777
|
|
|
@@ -774,7 +784,7 @@ This one's zip code is 92064.`;
|
|
|
774
784
|
['numberString', 31],
|
|
775
785
|
['pickles', 100],
|
|
776
786
|
],
|
|
777
|
-
}
|
|
787
|
+
},
|
|
778
788
|
);
|
|
779
789
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
780
790
|
|
|
@@ -787,7 +797,7 @@ This one's zip code is 92064.`;
|
|
|
787
797
|
['numberString', 29],
|
|
788
798
|
['pickles', 100],
|
|
789
799
|
],
|
|
790
|
-
}
|
|
800
|
+
},
|
|
791
801
|
);
|
|
792
802
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
793
803
|
});
|
|
@@ -804,7 +814,7 @@ This one's zip code is 92064.`;
|
|
|
804
814
|
['number', 30],
|
|
805
815
|
['pickles', 100],
|
|
806
816
|
],
|
|
807
|
-
}
|
|
817
|
+
},
|
|
808
818
|
);
|
|
809
819
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
810
820
|
|
|
@@ -817,7 +827,7 @@ This one's zip code is 92064.`;
|
|
|
817
827
|
['number', 31],
|
|
818
828
|
['pickles', 100],
|
|
819
829
|
],
|
|
820
|
-
}
|
|
830
|
+
},
|
|
821
831
|
);
|
|
822
832
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
823
833
|
|
|
@@ -830,7 +840,7 @@ This one's zip code is 92064.`;
|
|
|
830
840
|
['number', 29],
|
|
831
841
|
['pickles', 100],
|
|
832
842
|
],
|
|
833
|
-
}
|
|
843
|
+
},
|
|
834
844
|
);
|
|
835
845
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
836
846
|
|
|
@@ -843,7 +853,7 @@ This one's zip code is 92064.`;
|
|
|
843
853
|
['numberString', 30],
|
|
844
854
|
['pickles', 100],
|
|
845
855
|
],
|
|
846
|
-
}
|
|
856
|
+
},
|
|
847
857
|
);
|
|
848
858
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
849
859
|
|
|
@@ -856,7 +866,7 @@ This one's zip code is 92064.`;
|
|
|
856
866
|
['numberString', 31],
|
|
857
867
|
['pickles', 100],
|
|
858
868
|
],
|
|
859
|
-
}
|
|
869
|
+
},
|
|
860
870
|
);
|
|
861
871
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
862
872
|
|
|
@@ -869,7 +879,7 @@ This one's zip code is 92064.`;
|
|
|
869
879
|
['numberString', 29],
|
|
870
880
|
['pickles', 100],
|
|
871
881
|
],
|
|
872
|
-
}
|
|
882
|
+
},
|
|
873
883
|
);
|
|
874
884
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
875
885
|
});
|
|
@@ -886,7 +896,7 @@ This one's zip code is 92064.`;
|
|
|
886
896
|
['number', 30],
|
|
887
897
|
['pickles', 100],
|
|
888
898
|
],
|
|
889
|
-
}
|
|
899
|
+
},
|
|
890
900
|
);
|
|
891
901
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
892
902
|
|
|
@@ -899,7 +909,7 @@ This one's zip code is 92064.`;
|
|
|
899
909
|
['number', 31],
|
|
900
910
|
['pickles', 100],
|
|
901
911
|
],
|
|
902
|
-
}
|
|
912
|
+
},
|
|
903
913
|
);
|
|
904
914
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
905
915
|
|
|
@@ -912,7 +922,7 @@ This one's zip code is 92064.`;
|
|
|
912
922
|
['number', 29],
|
|
913
923
|
['pickles', 100],
|
|
914
924
|
],
|
|
915
|
-
}
|
|
925
|
+
},
|
|
916
926
|
);
|
|
917
927
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
918
928
|
|
|
@@ -925,7 +935,7 @@ This one's zip code is 92064.`;
|
|
|
925
935
|
['numberString', 30],
|
|
926
936
|
['pickles', 100],
|
|
927
937
|
],
|
|
928
|
-
}
|
|
938
|
+
},
|
|
929
939
|
);
|
|
930
940
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
931
941
|
|
|
@@ -938,7 +948,7 @@ This one's zip code is 92064.`;
|
|
|
938
948
|
['numberString', 31],
|
|
939
949
|
['pickles', 100],
|
|
940
950
|
],
|
|
941
|
-
}
|
|
951
|
+
},
|
|
942
952
|
);
|
|
943
953
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
944
954
|
|
|
@@ -951,7 +961,7 @@ This one's zip code is 92064.`;
|
|
|
951
961
|
['numberString', 29],
|
|
952
962
|
['pickles', 100],
|
|
953
963
|
],
|
|
954
|
-
}
|
|
964
|
+
},
|
|
955
965
|
);
|
|
956
966
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
957
967
|
});
|
|
@@ -968,7 +978,7 @@ This one's zip code is 92064.`;
|
|
|
968
978
|
['number', 30],
|
|
969
979
|
['pickles', 100],
|
|
970
980
|
],
|
|
971
|
-
}
|
|
981
|
+
},
|
|
972
982
|
);
|
|
973
983
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
974
984
|
|
|
@@ -981,7 +991,7 @@ This one's zip code is 92064.`;
|
|
|
981
991
|
['number', 31],
|
|
982
992
|
['pickles', 100],
|
|
983
993
|
],
|
|
984
|
-
}
|
|
994
|
+
},
|
|
985
995
|
);
|
|
986
996
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
987
997
|
|
|
@@ -994,7 +1004,7 @@ This one's zip code is 92064.`;
|
|
|
994
1004
|
['number', 29],
|
|
995
1005
|
['pickles', 100],
|
|
996
1006
|
],
|
|
997
|
-
}
|
|
1007
|
+
},
|
|
998
1008
|
);
|
|
999
1009
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1000
1010
|
|
|
@@ -1007,7 +1017,7 @@ This one's zip code is 92064.`;
|
|
|
1007
1017
|
['numberString', 30],
|
|
1008
1018
|
['pickles', 100],
|
|
1009
1019
|
],
|
|
1010
|
-
}
|
|
1020
|
+
},
|
|
1011
1021
|
);
|
|
1012
1022
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1013
1023
|
|
|
@@ -1020,7 +1030,7 @@ This one's zip code is 92064.`;
|
|
|
1020
1030
|
['numberString', 31],
|
|
1021
1031
|
['pickles', 100],
|
|
1022
1032
|
],
|
|
1023
|
-
}
|
|
1033
|
+
},
|
|
1024
1034
|
);
|
|
1025
1035
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1026
1036
|
|
|
@@ -1033,7 +1043,7 @@ This one's zip code is 92064.`;
|
|
|
1033
1043
|
['numberString', 29],
|
|
1034
1044
|
['pickles', 100],
|
|
1035
1045
|
],
|
|
1036
|
-
}
|
|
1046
|
+
},
|
|
1037
1047
|
);
|
|
1038
1048
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1039
1049
|
});
|
|
@@ -1045,7 +1055,7 @@ This one's zip code is 92064.`;
|
|
|
1045
1055
|
const resultEntity = await nymph.getEntities(
|
|
1046
1056
|
{ class: TestModel },
|
|
1047
1057
|
{ type: '&', tag: 'test' },
|
|
1048
|
-
{ type: '!&', gte: ['number', 60] }
|
|
1058
|
+
{ type: '!&', gte: ['number', 60] },
|
|
1049
1059
|
);
|
|
1050
1060
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1051
1061
|
});
|
|
@@ -1056,7 +1066,7 @@ This one's zip code is 92064.`;
|
|
|
1056
1066
|
// Testing wrong inequality...
|
|
1057
1067
|
const resultEntity = await nymph.getEntities(
|
|
1058
1068
|
{ class: TestModel },
|
|
1059
|
-
{ type: '&', lte: ['number', 29.99] }
|
|
1069
|
+
{ type: '&', lte: ['number', 29.99] },
|
|
1060
1070
|
);
|
|
1061
1071
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1062
1072
|
});
|
|
@@ -1067,7 +1077,7 @@ This one's zip code is 92064.`;
|
|
|
1067
1077
|
// Retrieving entity by time...
|
|
1068
1078
|
const resultEntity = await nymph.getEntities(
|
|
1069
1079
|
{ class: TestModel },
|
|
1070
|
-
{ type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] }
|
|
1080
|
+
{ type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] },
|
|
1071
1081
|
);
|
|
1072
1082
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1073
1083
|
});
|
|
@@ -1078,7 +1088,7 @@ This one's zip code is 92064.`;
|
|
|
1078
1088
|
// Testing wrong time...
|
|
1079
1089
|
const resultEntity = await nymph.getEntities(
|
|
1080
1090
|
{ class: TestModel },
|
|
1081
|
-
{ type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] }
|
|
1091
|
+
{ type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] },
|
|
1082
1092
|
);
|
|
1083
1093
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1084
1094
|
});
|
|
@@ -1091,7 +1101,7 @@ This one's zip code is 92064.`;
|
|
|
1091
1101
|
// Retrieving entity by relative time...
|
|
1092
1102
|
let resultEntity = await nymph.getEntities(
|
|
1093
1103
|
{ class: TestModel },
|
|
1094
|
-
{ type: '&', gt: ['timestamp', null, '-1 day'] }
|
|
1104
|
+
{ type: '&', gt: ['timestamp', null, '-1 day'] },
|
|
1095
1105
|
);
|
|
1096
1106
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1097
1107
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -1105,7 +1115,7 @@ This one's zip code is 92064.`;
|
|
|
1105
1115
|
['timestamp', null, '-1 day'],
|
|
1106
1116
|
['timestamp', null, '+5 days'],
|
|
1107
1117
|
],
|
|
1108
|
-
}
|
|
1118
|
+
},
|
|
1109
1119
|
);
|
|
1110
1120
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1111
1121
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -1113,7 +1123,7 @@ This one's zip code is 92064.`;
|
|
|
1113
1123
|
// Retrieving entity by relative time...
|
|
1114
1124
|
resultEntity = await nymph.getEntities(
|
|
1115
1125
|
{ class: TestModel },
|
|
1116
|
-
{ type: '&', gt: ['timestamp', null, '-3 days'] }
|
|
1126
|
+
{ type: '&', gt: ['timestamp', null, '-3 days'] },
|
|
1117
1127
|
);
|
|
1118
1128
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1119
1129
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
@@ -1121,7 +1131,7 @@ This one's zip code is 92064.`;
|
|
|
1121
1131
|
// Retrieving entity by relative time...
|
|
1122
1132
|
resultEntity = await nymph.getEntities(
|
|
1123
1133
|
{ class: TestModel },
|
|
1124
|
-
{ type: '&', gt: ['cdate', null, '-1 day'] }
|
|
1134
|
+
{ type: '&', gt: ['cdate', null, '-1 day'] },
|
|
1125
1135
|
);
|
|
1126
1136
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1127
1137
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
@@ -1135,7 +1145,7 @@ This one's zip code is 92064.`;
|
|
|
1135
1145
|
// Retrieving entity by relative time...
|
|
1136
1146
|
let resultEntity = await nymph.getEntities(
|
|
1137
1147
|
{ class: TestModel },
|
|
1138
|
-
{ type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] }
|
|
1148
|
+
{ type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] },
|
|
1139
1149
|
);
|
|
1140
1150
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1141
1151
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -1143,7 +1153,7 @@ This one's zip code is 92064.`;
|
|
|
1143
1153
|
// Retrieving entity by relative time...
|
|
1144
1154
|
resultEntity = await nymph.getEntities(
|
|
1145
1155
|
{ class: TestModel },
|
|
1146
|
-
{ type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] }
|
|
1156
|
+
{ type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] },
|
|
1147
1157
|
);
|
|
1148
1158
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1149
1159
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -1151,7 +1161,7 @@ This one's zip code is 92064.`;
|
|
|
1151
1161
|
// Retrieving entity by relative time...
|
|
1152
1162
|
resultEntity = await nymph.getEntities(
|
|
1153
1163
|
{ class: TestModel },
|
|
1154
|
-
{ type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] }
|
|
1164
|
+
{ type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] },
|
|
1155
1165
|
);
|
|
1156
1166
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1157
1167
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -1161,9 +1171,11 @@ This one's zip code is 92064.`;
|
|
|
1161
1171
|
await createTestEntities();
|
|
1162
1172
|
|
|
1163
1173
|
// Testing referenced entities...
|
|
1174
|
+
await testEntity.reference?.$wake();
|
|
1164
1175
|
expect(testEntity.reference?.test).toEqual('good');
|
|
1165
1176
|
|
|
1166
1177
|
// Testing referenced entity arrays...
|
|
1178
|
+
await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
|
|
1167
1179
|
expect(testEntity.refArray?.[0].test).toEqual('good');
|
|
1168
1180
|
});
|
|
1169
1181
|
|
|
@@ -1173,7 +1185,7 @@ This one's zip code is 92064.`;
|
|
|
1173
1185
|
// Retrieving entity by reference...
|
|
1174
1186
|
const resultEntity = await nymph.getEntities(
|
|
1175
1187
|
{ class: TestModel },
|
|
1176
|
-
{ type: '&', ref: ['reference', refGuid] }
|
|
1188
|
+
{ type: '&', ref: ['reference', refGuid] },
|
|
1177
1189
|
);
|
|
1178
1190
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1179
1191
|
});
|
|
@@ -1185,7 +1197,7 @@ This one's zip code is 92064.`;
|
|
|
1185
1197
|
const resultEntity = await nymph.getEntities(
|
|
1186
1198
|
{ class: TestModel },
|
|
1187
1199
|
{ type: '&', tag: 'test' },
|
|
1188
|
-
{ type: '!&', ref: ['reference', guid()] }
|
|
1200
|
+
{ type: '!&', ref: ['reference', guid()] },
|
|
1189
1201
|
);
|
|
1190
1202
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1191
1203
|
});
|
|
@@ -1196,7 +1208,7 @@ This one's zip code is 92064.`;
|
|
|
1196
1208
|
// Testing wrong reference...
|
|
1197
1209
|
const resultEntity = await nymph.getEntities(
|
|
1198
1210
|
{ class: TestModel },
|
|
1199
|
-
{ type: '&', ref: ['reference', guid()] }
|
|
1211
|
+
{ type: '&', ref: ['reference', guid()] },
|
|
1200
1212
|
);
|
|
1201
1213
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1202
1214
|
});
|
|
@@ -1207,7 +1219,7 @@ This one's zip code is 92064.`;
|
|
|
1207
1219
|
// Testing non-existent reference...
|
|
1208
1220
|
const resultEntity = await nymph.getEntities(
|
|
1209
1221
|
{ class: TestModel },
|
|
1210
|
-
{ type: '&', ref: ['pickle', refGuid] }
|
|
1222
|
+
{ type: '&', ref: ['pickle', refGuid] },
|
|
1211
1223
|
);
|
|
1212
1224
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1213
1225
|
});
|
|
@@ -1224,7 +1236,7 @@ This one's zip code is 92064.`;
|
|
|
1224
1236
|
['reference', refGuid],
|
|
1225
1237
|
['reference', guid()],
|
|
1226
1238
|
],
|
|
1227
|
-
}
|
|
1239
|
+
},
|
|
1228
1240
|
);
|
|
1229
1241
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1230
1242
|
});
|
|
@@ -1241,7 +1253,7 @@ This one's zip code is 92064.`;
|
|
|
1241
1253
|
['reference', guid()],
|
|
1242
1254
|
['reference', guid()],
|
|
1243
1255
|
],
|
|
1244
|
-
}
|
|
1256
|
+
},
|
|
1245
1257
|
);
|
|
1246
1258
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1247
1259
|
});
|
|
@@ -1252,7 +1264,7 @@ This one's zip code is 92064.`;
|
|
|
1252
1264
|
// Retrieving entity by array reference...
|
|
1253
1265
|
const resultEntity = await nymph.getEntities(
|
|
1254
1266
|
{ class: TestModel },
|
|
1255
|
-
{ type: '&', ref: ['refArray', refGuid] }
|
|
1267
|
+
{ type: '&', ref: ['refArray', refGuid] },
|
|
1256
1268
|
);
|
|
1257
1269
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1258
1270
|
});
|
|
@@ -1269,7 +1281,7 @@ This one's zip code is 92064.`;
|
|
|
1269
1281
|
['refArray', refGuid],
|
|
1270
1282
|
['refArray', guid()],
|
|
1271
1283
|
],
|
|
1272
|
-
}
|
|
1284
|
+
},
|
|
1273
1285
|
);
|
|
1274
1286
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1275
1287
|
});
|
|
@@ -1314,7 +1326,7 @@ This one's zip code is 92064.`;
|
|
|
1314
1326
|
['array', 'values'],
|
|
1315
1327
|
['array', 500],
|
|
1316
1328
|
],
|
|
1317
|
-
}
|
|
1329
|
+
},
|
|
1318
1330
|
);
|
|
1319
1331
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1320
1332
|
});
|
|
@@ -1334,13 +1346,13 @@ This one's zip code is 92064.`;
|
|
|
1334
1346
|
|
|
1335
1347
|
const resultSelectors = await nymph.getEntities(
|
|
1336
1348
|
{ class: TestModel },
|
|
1337
|
-
{ type: '&', ref: ['reference', refGuid] }
|
|
1349
|
+
{ type: '&', ref: ['reference', refGuid] },
|
|
1338
1350
|
);
|
|
1339
1351
|
|
|
1340
1352
|
// Testing count return with selectors...
|
|
1341
1353
|
const resultSelectorsCount = await nymph.getEntities(
|
|
1342
1354
|
{ class: TestModel, return: 'count' },
|
|
1343
|
-
{ type: '&', ref: ['reference', refGuid] }
|
|
1355
|
+
{ type: '&', ref: ['reference', refGuid] },
|
|
1344
1356
|
);
|
|
1345
1357
|
expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
|
|
1346
1358
|
expect(resultSelectorsCount).toEqual(resultSelectors.length);
|
|
@@ -1363,7 +1375,7 @@ This one's zip code is 92064.`;
|
|
|
1363
1375
|
// Testing empty count...
|
|
1364
1376
|
const resultSelectorsEmpty = await nymph.getEntities(
|
|
1365
1377
|
{ class: TestModel, return: 'count' },
|
|
1366
|
-
{ type: '&', ref: ['reference', guid()] }
|
|
1378
|
+
{ type: '&', ref: ['reference', guid()] },
|
|
1367
1379
|
);
|
|
1368
1380
|
expect(resultSelectorsEmpty).toEqual(0);
|
|
1369
1381
|
});
|
|
@@ -1408,7 +1420,7 @@ This one's zip code is 92064.`;
|
|
|
1408
1420
|
['array', 'values'],
|
|
1409
1421
|
['array', 500],
|
|
1410
1422
|
],
|
|
1411
|
-
}
|
|
1423
|
+
},
|
|
1412
1424
|
);
|
|
1413
1425
|
expect(resultGuid.indexOf(testEntity.guid ?? '')).toBeGreaterThan(-1);
|
|
1414
1426
|
});
|
|
@@ -1458,7 +1470,7 @@ This one's zip code is 92064.`;
|
|
|
1458
1470
|
],
|
|
1459
1471
|
},
|
|
1460
1472
|
],
|
|
1461
|
-
}
|
|
1473
|
+
},
|
|
1462
1474
|
);
|
|
1463
1475
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1464
1476
|
|
|
@@ -1503,7 +1515,7 @@ This one's zip code is 92064.`;
|
|
|
1503
1515
|
],
|
|
1504
1516
|
},
|
|
1505
1517
|
],
|
|
1506
|
-
}
|
|
1518
|
+
},
|
|
1507
1519
|
);
|
|
1508
1520
|
expect(testEntity.$inArray(resultEntity2)).toEqual(true);
|
|
1509
1521
|
|
|
@@ -1519,7 +1531,7 @@ This one's zip code is 92064.`;
|
|
|
1519
1531
|
},
|
|
1520
1532
|
{ type: '&', gte: ['number', 16000] },
|
|
1521
1533
|
],
|
|
1522
|
-
}
|
|
1534
|
+
},
|
|
1523
1535
|
);
|
|
1524
1536
|
expect(testEntity.$inArray(resultEntity3)).toEqual(true);
|
|
1525
1537
|
|
|
@@ -1541,7 +1553,7 @@ This one's zip code is 92064.`;
|
|
|
1541
1553
|
},
|
|
1542
1554
|
},
|
|
1543
1555
|
],
|
|
1544
|
-
}
|
|
1556
|
+
},
|
|
1545
1557
|
);
|
|
1546
1558
|
expect(testEntity.$inArray(resultEntity4)).toEqual(true);
|
|
1547
1559
|
});
|
|
@@ -1560,7 +1572,7 @@ This one's zip code is 92064.`;
|
|
|
1560
1572
|
},
|
|
1561
1573
|
{ type: '&', gte: ['number', 16000] },
|
|
1562
1574
|
],
|
|
1563
|
-
}
|
|
1575
|
+
},
|
|
1564
1576
|
);
|
|
1565
1577
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1566
1578
|
});
|
|
@@ -1577,7 +1589,7 @@ This one's zip code is 92064.`;
|
|
|
1577
1589
|
'reference',
|
|
1578
1590
|
[{ class: TestModel }, { type: '&', equal: ['test', 'good'] }],
|
|
1579
1591
|
],
|
|
1580
|
-
}
|
|
1592
|
+
},
|
|
1581
1593
|
);
|
|
1582
1594
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1583
1595
|
});
|
|
@@ -1594,7 +1606,7 @@ This one's zip code is 92064.`;
|
|
|
1594
1606
|
'reference',
|
|
1595
1607
|
[{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
|
|
1596
1608
|
],
|
|
1597
|
-
}
|
|
1609
|
+
},
|
|
1598
1610
|
);
|
|
1599
1611
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
1600
1612
|
});
|
|
@@ -1611,7 +1623,7 @@ This one's zip code is 92064.`;
|
|
|
1611
1623
|
'reference',
|
|
1612
1624
|
[{ class: TestBModel }, { type: '&', equal: ['test', 'good'] }],
|
|
1613
1625
|
],
|
|
1614
|
-
}
|
|
1626
|
+
},
|
|
1615
1627
|
);
|
|
1616
1628
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1617
1629
|
});
|
|
@@ -1628,31 +1640,28 @@ This one's zip code is 92064.`;
|
|
|
1628
1640
|
'reference',
|
|
1629
1641
|
[{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
|
|
1630
1642
|
],
|
|
1631
|
-
}
|
|
1643
|
+
},
|
|
1632
1644
|
);
|
|
1633
1645
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
1634
1646
|
});
|
|
1635
1647
|
|
|
1636
|
-
it('sort option', async () => {
|
|
1648
|
+
it('cdate and mdate sort option', async () => {
|
|
1637
1649
|
await createMultipleTestEntities();
|
|
1638
1650
|
|
|
1639
|
-
for (const sort of ['cdate', 'mdate']) {
|
|
1651
|
+
for (const sort of ['cdate', 'mdate'] as ('cdate' | 'mdate')[]) {
|
|
1640
1652
|
// Retrieving entities sorted...
|
|
1641
|
-
let resultEntities = await nymph.getEntities({
|
|
1642
|
-
class: TestModel,
|
|
1643
|
-
sort: sort as 'cdate' | 'mdate',
|
|
1644
|
-
});
|
|
1653
|
+
let resultEntities = await nymph.getEntities({ class: TestModel, sort });
|
|
1645
1654
|
expect(resultEntities.length).toBeGreaterThan(100);
|
|
1646
1655
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1647
|
-
expect(
|
|
1648
|
-
resultEntities[i
|
|
1649
|
-
)
|
|
1656
|
+
expect(resultEntities[i + 1][sort]).toBeGreaterThan(
|
|
1657
|
+
resultEntities[i][sort] ?? 0,
|
|
1658
|
+
);
|
|
1650
1659
|
}
|
|
1651
1660
|
|
|
1652
1661
|
// And test the same with guid return...
|
|
1653
1662
|
let resultGuids = await nymph.getEntities({
|
|
1654
1663
|
class: TestModel,
|
|
1655
|
-
sort
|
|
1664
|
+
sort,
|
|
1656
1665
|
return: 'guid',
|
|
1657
1666
|
});
|
|
1658
1667
|
expect(resultGuids.length).toBeGreaterThan(100);
|
|
@@ -1663,48 +1672,121 @@ This one's zip code is 92064.`;
|
|
|
1663
1672
|
// Retrieving entities reverse sorted...
|
|
1664
1673
|
resultEntities = await nymph.getEntities({
|
|
1665
1674
|
class: TestModel,
|
|
1666
|
-
sort
|
|
1675
|
+
sort,
|
|
1667
1676
|
reverse: true,
|
|
1668
1677
|
});
|
|
1669
1678
|
expect(resultEntities.length).toBeGreaterThan(100);
|
|
1670
1679
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1671
|
-
expect(resultEntities[i + 1][sort
|
|
1672
|
-
resultEntities[i][sort
|
|
1680
|
+
expect(resultEntities[i + 1][sort]).toBeLessThan(
|
|
1681
|
+
resultEntities[i][sort] ?? 0,
|
|
1673
1682
|
);
|
|
1674
1683
|
}
|
|
1675
1684
|
|
|
1676
1685
|
// And again with other selectors.
|
|
1677
1686
|
// Retrieving entities sorted...
|
|
1678
1687
|
resultEntities = await nymph.getEntities(
|
|
1679
|
-
{ class: TestModel, sort
|
|
1680
|
-
{ type: '&', match: ['name', '^Multi Test '] }
|
|
1688
|
+
{ class: TestModel, sort },
|
|
1689
|
+
{ type: '&', match: ['name', '^Multi Test '] },
|
|
1681
1690
|
);
|
|
1682
1691
|
expect(resultEntities.length).toEqual(100);
|
|
1683
1692
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1684
|
-
expect(
|
|
1685
|
-
resultEntities[i
|
|
1686
|
-
)
|
|
1693
|
+
expect(resultEntities[i + 1][sort]).toBeGreaterThan(
|
|
1694
|
+
resultEntities[i][sort] ?? 0,
|
|
1695
|
+
);
|
|
1687
1696
|
}
|
|
1688
1697
|
|
|
1689
1698
|
// Retrieving entities reverse sorted...
|
|
1690
1699
|
resultEntities = await nymph.getEntities(
|
|
1691
|
-
{ class: TestModel, sort
|
|
1692
|
-
{ type: '&', match: ['name', '^Multi Test '] }
|
|
1700
|
+
{ class: TestModel, sort, reverse: true },
|
|
1701
|
+
{ type: '&', match: ['name', '^Multi Test '] },
|
|
1693
1702
|
);
|
|
1694
1703
|
expect(resultEntities.length).toEqual(100);
|
|
1695
1704
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1696
|
-
expect(resultEntities[i + 1][sort
|
|
1697
|
-
resultEntities[i][sort
|
|
1705
|
+
expect(resultEntities[i + 1][sort]).toBeLessThan(
|
|
1706
|
+
resultEntities[i][sort] ?? 0,
|
|
1698
1707
|
);
|
|
1699
1708
|
}
|
|
1700
1709
|
}
|
|
1701
1710
|
});
|
|
1702
1711
|
|
|
1712
|
+
it('property sort option', async () => {
|
|
1713
|
+
await createMultipleTestEntities();
|
|
1714
|
+
|
|
1715
|
+
// Retrieving entities sorted...
|
|
1716
|
+
let resultEntities = await nymph.getEntities({
|
|
1717
|
+
class: TestModel,
|
|
1718
|
+
sort: 'number',
|
|
1719
|
+
});
|
|
1720
|
+
expect(resultEntities.length).toBeGreaterThan(100);
|
|
1721
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1722
|
+
expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThanOrEqual(
|
|
1723
|
+
resultEntities[i].number ?? 0,
|
|
1724
|
+
);
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
// And test the same with guid return...
|
|
1728
|
+
let resultGuids = await nymph.getEntities({
|
|
1729
|
+
class: TestModel,
|
|
1730
|
+
sort: 'number',
|
|
1731
|
+
return: 'guid',
|
|
1732
|
+
});
|
|
1733
|
+
expect(resultGuids.length).toBeGreaterThan(100);
|
|
1734
|
+
for (let i = 0; i < resultGuids.length - 1; i++) {
|
|
1735
|
+
expect(resultGuids[i]).toEqual(resultEntities[i].guid);
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// Retrieving entities reverse sorted...
|
|
1739
|
+
resultEntities = await nymph.getEntities({
|
|
1740
|
+
class: TestModel,
|
|
1741
|
+
sort: 'number',
|
|
1742
|
+
reverse: true,
|
|
1743
|
+
});
|
|
1744
|
+
expect(resultEntities.length).toBeGreaterThan(100);
|
|
1745
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1746
|
+
expect(resultEntities[i + 1].number ?? 0).toBeLessThanOrEqual(
|
|
1747
|
+
resultEntities[i].number ?? Infinity,
|
|
1748
|
+
);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// And again with other selectors.
|
|
1752
|
+
// Retrieving entities sorted...
|
|
1753
|
+
resultEntities = await nymph.getEntities(
|
|
1754
|
+
{ class: TestModel, sort: 'number' },
|
|
1755
|
+
{ type: '&', match: ['name', '^Multi Test '] },
|
|
1756
|
+
);
|
|
1757
|
+
expect(resultEntities.length).toEqual(100);
|
|
1758
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1759
|
+
expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThan(
|
|
1760
|
+
resultEntities[i].number ?? 0,
|
|
1761
|
+
);
|
|
1762
|
+
expect(resultEntities[i].name).toEqual(
|
|
1763
|
+
`Multi Test ${100 - (resultEntities[i].number ?? 0)}`,
|
|
1764
|
+
);
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
// Retrieving entities reverse sorted...
|
|
1768
|
+
resultEntities = await nymph.getEntities(
|
|
1769
|
+
{ class: TestModel, sort: 'number', reverse: true },
|
|
1770
|
+
{ type: '&', match: ['name', '^Multi Test '] },
|
|
1771
|
+
);
|
|
1772
|
+
expect(resultEntities.length).toEqual(100);
|
|
1773
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1774
|
+
expect(resultEntities[i + 1].number ?? 0).toBeLessThan(
|
|
1775
|
+
resultEntities[i].number ?? Infinity,
|
|
1776
|
+
);
|
|
1777
|
+
expect(resultEntities[i].name).toEqual(
|
|
1778
|
+
`Multi Test ${100 - (resultEntities[i].number ?? 0)}`,
|
|
1779
|
+
);
|
|
1780
|
+
}
|
|
1781
|
+
});
|
|
1782
|
+
|
|
1703
1783
|
it('delete reference', async () => {
|
|
1704
1784
|
await createTestEntities();
|
|
1705
1785
|
|
|
1706
1786
|
// Deleting referenced entities...
|
|
1787
|
+
await testEntity.reference?.$wake();
|
|
1707
1788
|
expect(await testEntity.reference?.$delete()).toEqual(true);
|
|
1789
|
+
await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
|
|
1708
1790
|
expect(testEntity.reference?.guid).toBeNull();
|
|
1709
1791
|
});
|
|
1710
1792
|
|
|
@@ -1717,7 +1799,7 @@ This one's zip code is 92064.`;
|
|
|
1717
1799
|
|
|
1718
1800
|
const entity = await nymph.getEntity(
|
|
1719
1801
|
{ class: TestModel },
|
|
1720
|
-
{ type: '&', guid: testGuid }
|
|
1802
|
+
{ type: '&', guid: testGuid },
|
|
1721
1803
|
);
|
|
1722
1804
|
|
|
1723
1805
|
expect(entity).toBeNull();
|
|
@@ -1726,11 +1808,8 @@ This one's zip code is 92064.`;
|
|
|
1726
1808
|
|
|
1727
1809
|
export function UIDTest(
|
|
1728
1810
|
nymph: Nymph,
|
|
1729
|
-
it: (name: string, fn: () => void) => void
|
|
1811
|
+
it: (name: string, fn: () => void) => void,
|
|
1730
1812
|
) {
|
|
1731
|
-
nymph.addEntityClass(TestModel);
|
|
1732
|
-
nymph.addEntityClass(TestBModel);
|
|
1733
|
-
|
|
1734
1813
|
it('delete old test data', async () => {
|
|
1735
1814
|
expect(await nymph.deleteUID('TestUID')).toEqual(true);
|
|
1736
1815
|
expect(await nymph.deleteUID('NewUID')).toEqual(true);
|
|
@@ -1770,10 +1849,10 @@ export function UIDTest(
|
|
|
1770
1849
|
|
|
1771
1850
|
export function ExportImportTest(
|
|
1772
1851
|
nymph: Nymph,
|
|
1773
|
-
it: (name: string, fn: () => void) => void
|
|
1852
|
+
it: (name: string, fn: () => void) => void,
|
|
1774
1853
|
) {
|
|
1775
|
-
nymph.addEntityClass(
|
|
1776
|
-
nymph.addEntityClass(
|
|
1854
|
+
const TestModel = nymph.addEntityClass(TestModelClass);
|
|
1855
|
+
const TestBModel = nymph.addEntityClass(TestBModelClass);
|
|
1777
1856
|
|
|
1778
1857
|
async function deleteTestData() {
|
|
1779
1858
|
let all = await nymph.getEntities({ class: TestModel });
|
|
@@ -1817,9 +1896,11 @@ export function ExportImportTest(
|
|
|
1817
1896
|
expect(model.number).toEqual(30);
|
|
1818
1897
|
expect(model.timestamp).toBeGreaterThanOrEqual(strtotime('-2 minutes'));
|
|
1819
1898
|
|
|
1899
|
+
await model.reference?.$wake();
|
|
1820
1900
|
expect(model.reference?.guid).not.toBeNull();
|
|
1821
1901
|
expect(model.reference?.string).toEqual('another');
|
|
1822
1902
|
expect(model.reference?.index?.match(/^\d+b$/)).toBeTruthy();
|
|
1903
|
+
await Promise.all(model.refArray?.map((e) => e.$wake()) || []);
|
|
1823
1904
|
expect(model.refArray?.[0].guid).not.toBeNull();
|
|
1824
1905
|
expect(model.refArray?.[0].guid).toEqual(model.reference?.guid);
|
|
1825
1906
|
}
|
|
@@ -1866,7 +1947,7 @@ export function ExportImportTest(
|
|
|
1866
1947
|
|
|
1867
1948
|
it('export data', async () => {
|
|
1868
1949
|
expect(await nymph.export(__dirname + '/testentityexport.nex')).toEqual(
|
|
1869
|
-
true
|
|
1950
|
+
true,
|
|
1870
1951
|
);
|
|
1871
1952
|
});
|
|
1872
1953
|
|
|
@@ -1883,7 +1964,7 @@ export function ExportImportTest(
|
|
|
1883
1964
|
expect(bmodels.length).toEqual(0);
|
|
1884
1965
|
|
|
1885
1966
|
expect(await nymph.import(__dirname + '/testentityexport.nex')).toEqual(
|
|
1886
|
-
true
|
|
1967
|
+
true,
|
|
1887
1968
|
);
|
|
1888
1969
|
|
|
1889
1970
|
await checkEntityDataAndCount();
|