@nymphjs/nymph 1.0.0-beta.55 → 1.0.0-beta.57
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 +12 -0
- package/dist/Entity.d.ts +191 -0
- package/dist/Entity.js +179 -0
- package/dist/Entity.js.map +1 -1
- package/dist/Entity.test.js +6 -0
- package/dist/Entity.test.js.map +1 -1
- package/dist/Entity.types.d.ts +258 -0
- package/dist/Nymph.d.ts +389 -0
- package/dist/Nymph.js +501 -179
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +12 -1
- package/dist/Nymph.types.js +1 -0
- package/dist/Nymph.types.js.map +1 -1
- package/dist/conf/d.d.ts +26 -0
- package/dist/conf/defaults.js +22 -0
- package/dist/conf/defaults.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +61 -1
- package/dist/driver/NymphDriver.js +220 -123
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/testArtifacts.js +142 -0
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/errors/EntityInvalidDataError.d.ts +6 -0
- package/dist/errors/EntityInvalidDataError.js +6 -0
- package/dist/errors/EntityInvalidDataError.js.map +1 -1
- package/dist/testArtifacts.d.ts +9 -0
- package/dist/testArtifacts.js +9 -0
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.js +2 -0
- package/dist/testMocks.js.map +1 -1
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -1
- package/package.json +5 -3
- package/src/Nymph.ts +281 -177
- package/src/Nymph.types.ts +1 -1
- package/src/conf/d.ts +8 -0
- package/src/conf/defaults.ts +24 -0
- package/src/driver/NymphDriver.ts +198 -183
- package/tsconfig.json +1 -1
|
@@ -16,11 +16,14 @@ function QueriesTest(nymph, it) {
|
|
|
16
16
|
let testGuid;
|
|
17
17
|
let refGuid;
|
|
18
18
|
let createdMultiple = false;
|
|
19
|
+
// The entities created by this function are required by many of the tests.
|
|
19
20
|
async function createTestEntities() {
|
|
20
21
|
if (testGuid != null) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
24
|
+
// Creating entity...
|
|
23
25
|
testEntity = await TestModel.factory();
|
|
26
|
+
// Saving entity...
|
|
24
27
|
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
25
28
|
testEntity.null = null;
|
|
26
29
|
testEntity.string = 'test';
|
|
@@ -49,20 +52,25 @@ These hats are absolutely fantastic.`;
|
|
|
49
52
|
expect(await testEntity.$save()).toEqual(true);
|
|
50
53
|
entityReferenceTest.test = 'good';
|
|
51
54
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
55
|
+
// Test asynchronous getEntity.
|
|
52
56
|
testEntity = (await nymph.getEntity({ class: TestModel }, testGuid));
|
|
53
57
|
expect(testEntity).toBeInstanceOf(TestModel);
|
|
54
58
|
expect(testEntity.guid).toEqual(testGuid);
|
|
55
59
|
}
|
|
60
|
+
// The entities created by this function are required by many of the tests.
|
|
56
61
|
async function createMultipleTestEntities() {
|
|
57
62
|
if (!createdMultiple) {
|
|
58
63
|
createdMultiple = true;
|
|
64
|
+
// Creating 100 entities...
|
|
59
65
|
for (let i = 0; i < 100; i++) {
|
|
60
66
|
const testEntity = await TestModel.factory();
|
|
61
67
|
testEntity.name = `Multi Test ${i}`;
|
|
68
|
+
// Reverse the number for sort testing.
|
|
62
69
|
testEntity.number = 100 - i;
|
|
63
70
|
testEntity.$removeTag('test');
|
|
64
71
|
testEntity.$addTag('multiTest');
|
|
65
72
|
expect(await testEntity.$save()).toEqual(true);
|
|
73
|
+
// Pause for a few milliseconds so the cdate and mdate can be sorted.
|
|
66
74
|
await new Promise((res) => setTimeout(() => res(1), 5));
|
|
67
75
|
}
|
|
68
76
|
}
|
|
@@ -96,15 +104,19 @@ These hats are absolutely fantastic.`;
|
|
|
96
104
|
});
|
|
97
105
|
it('by guid', async () => {
|
|
98
106
|
await createTestEntities();
|
|
107
|
+
// Retrieving entity by GUID...
|
|
99
108
|
let resultEntity = await nymph.getEntity({ class: TestModel }, testGuid);
|
|
100
109
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
110
|
+
// Using class constructor...
|
|
101
111
|
resultEntity = await TestModel.factory(testGuid);
|
|
102
112
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
113
|
+
// Testing wrong GUID...
|
|
103
114
|
resultEntity = await nymph.getEntity({ class: TestModel }, (0, guid_1.guid)());
|
|
104
115
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
105
116
|
});
|
|
106
117
|
it('transactions', async () => {
|
|
107
118
|
await createTestEntities();
|
|
119
|
+
// Verify not in a transaction.
|
|
108
120
|
expect(await nymph.inTransaction()).toEqual(false);
|
|
109
121
|
let transaction = await nymph.startTransaction('test');
|
|
110
122
|
testEntity.$nymph = transaction;
|
|
@@ -113,37 +125,56 @@ These hats are absolutely fantastic.`;
|
|
|
113
125
|
await transaction.rollback('test');
|
|
114
126
|
return;
|
|
115
127
|
}
|
|
128
|
+
// Change a value in the test entity.
|
|
116
129
|
testEntity.string = 'bad value';
|
|
117
130
|
expect(await testEntity.$save()).toEqual(true);
|
|
131
|
+
// Rollback the transaction.
|
|
118
132
|
await transaction.rollback('test');
|
|
133
|
+
// Verify not in a transaction.
|
|
119
134
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
135
|
+
// Verify the value is correct.
|
|
120
136
|
await testEntity.$refresh();
|
|
121
137
|
expect(testEntity.string).toEqual('test');
|
|
138
|
+
// Start a new transaction.
|
|
122
139
|
transaction = await nymph.startTransaction('test');
|
|
123
140
|
testEntity.$nymph = transaction;
|
|
141
|
+
// Verify in a transaction.
|
|
124
142
|
expect(await transaction.inTransaction()).toEqual(true);
|
|
143
|
+
// Delete the entity.
|
|
125
144
|
expect(await testEntity.$delete()).toEqual(true);
|
|
126
145
|
const resultEntity = await transaction.getEntity({ class: TestModel }, testGuid);
|
|
127
146
|
expect(resultEntity).toBeNull();
|
|
147
|
+
// Rollback the transaction.
|
|
128
148
|
await transaction.rollback('test');
|
|
149
|
+
// Verify not in a transaction.
|
|
129
150
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
151
|
+
// Verify it's back.
|
|
130
152
|
testEntity = (await transaction.getEntity({ class: TestModel }, testGuid));
|
|
131
153
|
expect(testEntity.guid).toEqual(testGuid);
|
|
154
|
+
// Start a new transaction with a dot in the name.
|
|
132
155
|
transaction = await nymph.startTransaction('test.1');
|
|
133
156
|
testEntity.$nymph = transaction;
|
|
157
|
+
// Verify in a transaction.
|
|
134
158
|
expect(await transaction.inTransaction()).toEqual(true);
|
|
159
|
+
// Make a change.
|
|
135
160
|
testEntity.string = 'fish';
|
|
136
161
|
expect(await testEntity.$save()).toEqual(true);
|
|
162
|
+
// Commit the transaction.
|
|
137
163
|
await transaction.commit('test.1');
|
|
138
164
|
testEntity.$nymph = nymph;
|
|
165
|
+
// Verify not in a transaction.
|
|
139
166
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
167
|
+
// Verify the value is correct.
|
|
140
168
|
await testEntity.$refresh();
|
|
141
169
|
expect(testEntity.string).toEqual('fish');
|
|
170
|
+
// Finally, change it back.
|
|
142
171
|
testEntity.string = 'test';
|
|
143
172
|
expect(await testEntity.$save()).toEqual(true);
|
|
173
|
+
// TODO: nested transactions
|
|
144
174
|
});
|
|
145
175
|
it('options', async () => {
|
|
146
176
|
await createTestEntities();
|
|
177
|
+
// Testing entity order, offset, limit...
|
|
147
178
|
const resultEntities = await nymph.getEntities({
|
|
148
179
|
class: TestModel,
|
|
149
180
|
reverse: true,
|
|
@@ -156,86 +187,103 @@ These hats are absolutely fantastic.`;
|
|
|
156
187
|
});
|
|
157
188
|
it('guid and tags', async () => {
|
|
158
189
|
await createTestEntities();
|
|
190
|
+
// Retrieving entity by GUID and tags...
|
|
159
191
|
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid, tag: 'test' });
|
|
160
192
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
161
193
|
});
|
|
162
194
|
it('or selector', async () => {
|
|
163
195
|
await createTestEntities();
|
|
196
|
+
// Retrieving entity by GUID and tags...
|
|
164
197
|
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '|', guid: [testGuid, (0, guid_1.guid)()] });
|
|
165
198
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
166
199
|
});
|
|
167
200
|
it('wrong or selector', async () => {
|
|
168
201
|
await createTestEntities();
|
|
202
|
+
// Retrieving entity by GUID and tags...
|
|
169
203
|
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '|', guid: [(0, guid_1.guid)(), (0, guid_1.guid)()] });
|
|
170
204
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
171
205
|
});
|
|
172
206
|
it('not guid', async () => {
|
|
173
207
|
await createTestEntities();
|
|
208
|
+
// Retrieving entity by !GUID...
|
|
174
209
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', '!guid': (0, guid_1.guid)(), tag: 'test' });
|
|
175
210
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
176
211
|
});
|
|
177
212
|
it('not tags', async () => {
|
|
178
213
|
await createTestEntities();
|
|
214
|
+
// Retrieving entity by !tags...
|
|
179
215
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] });
|
|
180
216
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
181
217
|
});
|
|
182
218
|
it('guid and wrong tags', async () => {
|
|
183
219
|
await createTestEntities();
|
|
220
|
+
// Testing GUID and wrong tags...
|
|
184
221
|
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid, tag: ['pickles'] });
|
|
185
222
|
expect(resultEntity).toBeNull();
|
|
186
223
|
});
|
|
187
224
|
it('tags', async () => {
|
|
188
225
|
await createTestEntities();
|
|
226
|
+
// Retrieving entity by tags...
|
|
189
227
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' });
|
|
190
228
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
191
229
|
});
|
|
192
230
|
it('wrong tags', async () => {
|
|
193
231
|
await createTestEntities();
|
|
232
|
+
// Testing wrong tags...
|
|
194
233
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles' });
|
|
195
234
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
196
235
|
});
|
|
197
236
|
it('inclusive tags', async () => {
|
|
198
237
|
await createTestEntities();
|
|
238
|
+
// Retrieving entity by tags inclusively...
|
|
199
239
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '|', tag: ['pickles', 'test', 'barbecue'] });
|
|
200
240
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
201
241
|
});
|
|
202
242
|
it('wrong inclusive tags', async () => {
|
|
203
243
|
await createTestEntities();
|
|
244
|
+
// Testing wrong inclusive tags...
|
|
204
245
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '|', tag: ['pickles', 'barbecue'] });
|
|
205
246
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
206
247
|
});
|
|
207
248
|
it('mixed tags', async () => {
|
|
208
249
|
await createTestEntities();
|
|
250
|
+
// Retrieving entity by mixed tags...
|
|
209
251
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', tag: ['pickles', 'test', 'barbecue'] });
|
|
210
252
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
211
253
|
});
|
|
212
254
|
it('wrong inclusive mixed tags', async () => {
|
|
213
255
|
await createTestEntities();
|
|
256
|
+
// Testing wrong inclusive mixed tags...
|
|
214
257
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', tag: ['pickles', 'barbecue'] });
|
|
215
258
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
216
259
|
});
|
|
217
260
|
it('wrong exclusive mixed tags', async () => {
|
|
218
261
|
await createTestEntities();
|
|
262
|
+
// Testing wrong exclusive mixed tags...
|
|
219
263
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles' }, { type: '|', tag: ['test', 'barbecue'] });
|
|
220
264
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
221
265
|
});
|
|
222
266
|
it('defined', async () => {
|
|
223
267
|
await createTestEntities();
|
|
268
|
+
// Retrieving entity by defined...
|
|
224
269
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', defined: 'string' });
|
|
225
270
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
226
271
|
});
|
|
227
272
|
it('not defined', async () => {
|
|
228
273
|
await createTestEntities();
|
|
274
|
+
// Retrieving entity by !defined...
|
|
229
275
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!defined': 'pickles' });
|
|
230
276
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
231
277
|
});
|
|
232
278
|
it('defined in a not and clause', async () => {
|
|
233
279
|
await createTestEntities();
|
|
280
|
+
// Retrieving entity by defined in not and clause...
|
|
234
281
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '!&', defined: 'pickles' }, { type: '&', tag: 'test' });
|
|
235
282
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
236
283
|
});
|
|
237
284
|
it('equal', async () => {
|
|
238
285
|
await createTestEntities();
|
|
286
|
+
// Retrieving entity by equal...
|
|
239
287
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', equal: ['string', 'test'] });
|
|
240
288
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
241
289
|
});
|
|
@@ -243,12 +291,14 @@ These hats are absolutely fantastic.`;
|
|
|
243
291
|
await createTestEntities();
|
|
244
292
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
245
293
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
294
|
+
// Retrieving entity by !equal...
|
|
246
295
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!equal': ['string', 'wrong'] });
|
|
247
296
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
248
297
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
249
298
|
});
|
|
250
299
|
it('like', async () => {
|
|
251
300
|
await createTestEntities();
|
|
301
|
+
// Retrieving entity by like...
|
|
252
302
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', like: ['string', 't_s%'] });
|
|
253
303
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
254
304
|
});
|
|
@@ -256,12 +306,14 @@ These hats are absolutely fantastic.`;
|
|
|
256
306
|
await createTestEntities();
|
|
257
307
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
258
308
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
309
|
+
// Retrieving entity by !like...
|
|
259
310
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!like': ['string', 'wr_n%'] });
|
|
260
311
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
261
312
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
262
313
|
});
|
|
263
314
|
it('ilike', async () => {
|
|
264
315
|
await createTestEntities();
|
|
316
|
+
// Retrieving entity by ilike...
|
|
265
317
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ilike: ['string', 'T_s%'] });
|
|
266
318
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
267
319
|
});
|
|
@@ -269,56 +321,68 @@ These hats are absolutely fantastic.`;
|
|
|
269
321
|
await createTestEntities();
|
|
270
322
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
271
323
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
324
|
+
// Retrieving entity by !ilike...
|
|
272
325
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] });
|
|
273
326
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
274
327
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
275
328
|
});
|
|
276
329
|
it('like with wrong case', async () => {
|
|
277
330
|
await createTestEntities();
|
|
331
|
+
// Retrieving entity by like...
|
|
278
332
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', like: ['string', 'T_s%'] });
|
|
279
333
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
280
334
|
});
|
|
281
335
|
it('tags and equal', async () => {
|
|
282
336
|
await createTestEntities();
|
|
337
|
+
// Retrieving entity by tags and equal...
|
|
283
338
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', equal: ['string', 'test'] });
|
|
284
339
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
285
340
|
});
|
|
286
341
|
it('wrong tags right equal', async () => {
|
|
287
342
|
await createTestEntities();
|
|
343
|
+
// Testing wrong tags and right equal...
|
|
288
344
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles', equal: ['string', 'test'] });
|
|
289
345
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
290
346
|
});
|
|
291
347
|
it('right tags wrong equal', async () => {
|
|
292
348
|
await createTestEntities();
|
|
349
|
+
// Testing right tags and wrong equal...
|
|
293
350
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', equal: ['string', 'pickles'] });
|
|
294
351
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
295
352
|
});
|
|
296
353
|
it('wrong tags wrong equal', async () => {
|
|
297
354
|
await createTestEntities();
|
|
355
|
+
// Testing wrong tags and wrong equal...
|
|
298
356
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles', equal: ['string', 'pickles'] });
|
|
299
357
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
300
358
|
});
|
|
301
359
|
it('contain', async () => {
|
|
302
360
|
await createTestEntities();
|
|
361
|
+
// Retrieving entity by contain...
|
|
303
362
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 'values'] });
|
|
304
363
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
364
|
+
// Retrieving entity by contain with full match...
|
|
305
365
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['string', 'test'] });
|
|
306
366
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
307
367
|
});
|
|
308
368
|
it('not contain', async () => {
|
|
309
369
|
await createTestEntities();
|
|
370
|
+
// Retrieving entity by !contain...
|
|
310
371
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', contain: ['array', 'pickles'] });
|
|
311
372
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
312
373
|
});
|
|
313
374
|
it('wrong contain', async () => {
|
|
314
375
|
await createTestEntities();
|
|
376
|
+
// Testing wrong contain...
|
|
315
377
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 'pickles'] });
|
|
316
378
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
379
|
+
// Testing wrong contain...
|
|
317
380
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['string', 'pickles'] });
|
|
318
381
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
319
382
|
});
|
|
320
383
|
it('match', async () => {
|
|
321
384
|
await createTestEntities();
|
|
385
|
+
// Retrieving entity by regex match...
|
|
322
386
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', match: ['match', '.*'] });
|
|
323
387
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
324
388
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', match: ['match', 'Edward McCheese'] });
|
|
@@ -346,11 +410,13 @@ These hats are absolutely fantastic.`;
|
|
|
346
410
|
});
|
|
347
411
|
it('imatch', async () => {
|
|
348
412
|
await createTestEntities();
|
|
413
|
+
// Retrieving entity by regex match...
|
|
349
414
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] });
|
|
350
415
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
351
416
|
});
|
|
352
417
|
it('wrong match', async () => {
|
|
353
418
|
await createTestEntities();
|
|
419
|
+
// Testing wrong regex match...
|
|
354
420
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', match: ['match', 'Q'] });
|
|
355
421
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
356
422
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickle', match: ['match', '.*'] });
|
|
@@ -366,16 +432,19 @@ These hats are absolutely fantastic.`;
|
|
|
366
432
|
});
|
|
367
433
|
it('match wrong case', async () => {
|
|
368
434
|
await createTestEntities();
|
|
435
|
+
// Retrieving entity by regex match...
|
|
369
436
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', match: ['match', 'edward mccheese'] });
|
|
370
437
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
371
438
|
});
|
|
372
439
|
it('match and equal inclusive', async () => {
|
|
373
440
|
await createTestEntities();
|
|
441
|
+
// Retrieving entity by regex + equal inclusively...
|
|
374
442
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', equal: ['string', 'pickles'], match: ['string', 'test'] });
|
|
375
443
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
376
444
|
});
|
|
377
445
|
it('greater than', async () => {
|
|
378
446
|
await createTestEntities();
|
|
447
|
+
// Retrieving entity by inequality...
|
|
379
448
|
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
380
449
|
type: '|',
|
|
381
450
|
gt: [
|
|
@@ -384,6 +453,7 @@ These hats are absolutely fantastic.`;
|
|
|
384
453
|
],
|
|
385
454
|
});
|
|
386
455
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
456
|
+
// Retrieving entity by inequality...
|
|
387
457
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
388
458
|
type: '|',
|
|
389
459
|
gt: [
|
|
@@ -392,6 +462,7 @@ These hats are absolutely fantastic.`;
|
|
|
392
462
|
],
|
|
393
463
|
});
|
|
394
464
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
465
|
+
// Retrieving entity by inequality...
|
|
395
466
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
396
467
|
type: '|',
|
|
397
468
|
gt: [
|
|
@@ -400,6 +471,7 @@ These hats are absolutely fantastic.`;
|
|
|
400
471
|
],
|
|
401
472
|
});
|
|
402
473
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
474
|
+
// Retrieving entity by inequality...
|
|
403
475
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
404
476
|
type: '|',
|
|
405
477
|
gt: [
|
|
@@ -408,6 +480,7 @@ These hats are absolutely fantastic.`;
|
|
|
408
480
|
],
|
|
409
481
|
});
|
|
410
482
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
483
|
+
// Retrieving entity by inequality...
|
|
411
484
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
412
485
|
type: '|',
|
|
413
486
|
gt: [
|
|
@@ -416,6 +489,7 @@ These hats are absolutely fantastic.`;
|
|
|
416
489
|
],
|
|
417
490
|
});
|
|
418
491
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
492
|
+
// Retrieving entity by inequality...
|
|
419
493
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
420
494
|
type: '|',
|
|
421
495
|
gt: [
|
|
@@ -427,6 +501,7 @@ These hats are absolutely fantastic.`;
|
|
|
427
501
|
});
|
|
428
502
|
it('greater than or equal', async () => {
|
|
429
503
|
await createTestEntities();
|
|
504
|
+
// Retrieving entity by inequality...
|
|
430
505
|
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
431
506
|
type: '|',
|
|
432
507
|
gte: [
|
|
@@ -435,6 +510,7 @@ These hats are absolutely fantastic.`;
|
|
|
435
510
|
],
|
|
436
511
|
});
|
|
437
512
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
513
|
+
// Retrieving entity by inequality...
|
|
438
514
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
439
515
|
type: '|',
|
|
440
516
|
gte: [
|
|
@@ -443,6 +519,7 @@ These hats are absolutely fantastic.`;
|
|
|
443
519
|
],
|
|
444
520
|
});
|
|
445
521
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
522
|
+
// Retrieving entity by inequality...
|
|
446
523
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
447
524
|
type: '|',
|
|
448
525
|
gte: [
|
|
@@ -451,6 +528,7 @@ These hats are absolutely fantastic.`;
|
|
|
451
528
|
],
|
|
452
529
|
});
|
|
453
530
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
531
|
+
// Retrieving entity by inequality...
|
|
454
532
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
455
533
|
type: '|',
|
|
456
534
|
gte: [
|
|
@@ -459,6 +537,7 @@ These hats are absolutely fantastic.`;
|
|
|
459
537
|
],
|
|
460
538
|
});
|
|
461
539
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
540
|
+
// Retrieving entity by inequality...
|
|
462
541
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
463
542
|
type: '|',
|
|
464
543
|
gte: [
|
|
@@ -467,6 +546,7 @@ These hats are absolutely fantastic.`;
|
|
|
467
546
|
],
|
|
468
547
|
});
|
|
469
548
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
549
|
+
// Retrieving entity by inequality...
|
|
470
550
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
471
551
|
type: '|',
|
|
472
552
|
gte: [
|
|
@@ -478,6 +558,7 @@ These hats are absolutely fantastic.`;
|
|
|
478
558
|
});
|
|
479
559
|
it('less than', async () => {
|
|
480
560
|
await createTestEntities();
|
|
561
|
+
// Retrieving entity by inequality...
|
|
481
562
|
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
482
563
|
type: '|',
|
|
483
564
|
lt: [
|
|
@@ -486,6 +567,7 @@ These hats are absolutely fantastic.`;
|
|
|
486
567
|
],
|
|
487
568
|
});
|
|
488
569
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
570
|
+
// Retrieving entity by inequality...
|
|
489
571
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
490
572
|
type: '|',
|
|
491
573
|
lt: [
|
|
@@ -494,6 +576,7 @@ These hats are absolutely fantastic.`;
|
|
|
494
576
|
],
|
|
495
577
|
});
|
|
496
578
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
579
|
+
// Retrieving entity by inequality...
|
|
497
580
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
498
581
|
type: '|',
|
|
499
582
|
lt: [
|
|
@@ -502,6 +585,7 @@ These hats are absolutely fantastic.`;
|
|
|
502
585
|
],
|
|
503
586
|
});
|
|
504
587
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
588
|
+
// Retrieving entity by inequality...
|
|
505
589
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
506
590
|
type: '|',
|
|
507
591
|
lt: [
|
|
@@ -510,6 +594,7 @@ These hats are absolutely fantastic.`;
|
|
|
510
594
|
],
|
|
511
595
|
});
|
|
512
596
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
597
|
+
// Retrieving entity by inequality...
|
|
513
598
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
514
599
|
type: '|',
|
|
515
600
|
lt: [
|
|
@@ -518,6 +603,7 @@ These hats are absolutely fantastic.`;
|
|
|
518
603
|
],
|
|
519
604
|
});
|
|
520
605
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
606
|
+
// Retrieving entity by inequality...
|
|
521
607
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
522
608
|
type: '|',
|
|
523
609
|
lt: [
|
|
@@ -529,6 +615,7 @@ These hats are absolutely fantastic.`;
|
|
|
529
615
|
});
|
|
530
616
|
it('less than or equal', async () => {
|
|
531
617
|
await createTestEntities();
|
|
618
|
+
// Retrieving entity by inequality...
|
|
532
619
|
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
533
620
|
type: '|',
|
|
534
621
|
lte: [
|
|
@@ -537,6 +624,7 @@ These hats are absolutely fantastic.`;
|
|
|
537
624
|
],
|
|
538
625
|
});
|
|
539
626
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
627
|
+
// Retrieving entity by inequality...
|
|
540
628
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
541
629
|
type: '|',
|
|
542
630
|
lte: [
|
|
@@ -545,6 +633,7 @@ These hats are absolutely fantastic.`;
|
|
|
545
633
|
],
|
|
546
634
|
});
|
|
547
635
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
636
|
+
// Retrieving entity by inequality...
|
|
548
637
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
549
638
|
type: '|',
|
|
550
639
|
lte: [
|
|
@@ -553,6 +642,7 @@ These hats are absolutely fantastic.`;
|
|
|
553
642
|
],
|
|
554
643
|
});
|
|
555
644
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
645
|
+
// Retrieving entity by inequality...
|
|
556
646
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
557
647
|
type: '|',
|
|
558
648
|
lte: [
|
|
@@ -561,6 +651,7 @@ These hats are absolutely fantastic.`;
|
|
|
561
651
|
],
|
|
562
652
|
});
|
|
563
653
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
654
|
+
// Retrieving entity by inequality...
|
|
564
655
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
565
656
|
type: '|',
|
|
566
657
|
lte: [
|
|
@@ -569,6 +660,7 @@ These hats are absolutely fantastic.`;
|
|
|
569
660
|
],
|
|
570
661
|
});
|
|
571
662
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
663
|
+
// Retrieving entity by inequality...
|
|
572
664
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
573
665
|
type: '|',
|
|
574
666
|
lte: [
|
|
@@ -580,30 +672,36 @@ These hats are absolutely fantastic.`;
|
|
|
580
672
|
});
|
|
581
673
|
it('not inequality', async () => {
|
|
582
674
|
await createTestEntities();
|
|
675
|
+
// Retrieving entity by !inequality...
|
|
583
676
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', gte: ['number', 60] });
|
|
584
677
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
585
678
|
});
|
|
586
679
|
it('wrong inequality', async () => {
|
|
587
680
|
await createTestEntities();
|
|
681
|
+
// Testing wrong inequality...
|
|
588
682
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', lte: ['number', 29.99] });
|
|
589
683
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
590
684
|
});
|
|
591
685
|
it('greater than cdate', async () => {
|
|
592
686
|
await createTestEntities();
|
|
687
|
+
// Retrieving entity by time...
|
|
593
688
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] });
|
|
594
689
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
595
690
|
});
|
|
596
691
|
it('wrong cdate', async () => {
|
|
597
692
|
await createTestEntities();
|
|
693
|
+
// Testing wrong time...
|
|
598
694
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] });
|
|
599
695
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
600
696
|
});
|
|
601
697
|
it('time selector', async () => {
|
|
602
698
|
await createTestEntities();
|
|
603
699
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
700
|
+
// Retrieving entity by relative time...
|
|
604
701
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['timestamp', null, '-1 day'] });
|
|
605
702
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
606
703
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
704
|
+
// Retrieving entity by relative time inclusively...
|
|
607
705
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
608
706
|
type: '|',
|
|
609
707
|
gt: [
|
|
@@ -613,9 +711,11 @@ These hats are absolutely fantastic.`;
|
|
|
613
711
|
});
|
|
614
712
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
615
713
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
714
|
+
// Retrieving entity by relative time...
|
|
616
715
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['timestamp', null, '-3 days'] });
|
|
617
716
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
618
717
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
718
|
+
// Retrieving entity by relative time...
|
|
619
719
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['cdate', null, '-1 day'] });
|
|
620
720
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
621
721
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
@@ -623,45 +723,55 @@ These hats are absolutely fantastic.`;
|
|
|
623
723
|
it('wrong time selector', async () => {
|
|
624
724
|
await createTestEntities();
|
|
625
725
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
726
|
+
// Retrieving entity by relative time...
|
|
626
727
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] });
|
|
627
728
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
628
729
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
730
|
+
// Retrieving entity by relative time...
|
|
629
731
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] });
|
|
630
732
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
631
733
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
734
|
+
// Retrieving entity by relative time...
|
|
632
735
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] });
|
|
633
736
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
634
737
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
635
738
|
});
|
|
636
739
|
it('references', async () => {
|
|
637
740
|
await createTestEntities();
|
|
741
|
+
// Testing referenced entities...
|
|
638
742
|
await testEntity.reference?.$wake();
|
|
639
743
|
expect(testEntity.reference?.test).toEqual('good');
|
|
744
|
+
// Testing referenced entity arrays...
|
|
640
745
|
await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
|
|
641
746
|
expect(testEntity.refArray?.[0].test).toEqual('good');
|
|
642
747
|
});
|
|
643
748
|
it('ref', async () => {
|
|
644
749
|
await createTestEntities();
|
|
750
|
+
// Retrieving entity by reference...
|
|
645
751
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', refGuid] });
|
|
646
752
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
647
753
|
});
|
|
648
754
|
it('not ref', async () => {
|
|
649
755
|
await createTestEntities();
|
|
756
|
+
// Retrieving entity by !reference...
|
|
650
757
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', ref: ['reference', (0, guid_1.guid)()] });
|
|
651
758
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
652
759
|
});
|
|
653
760
|
it('wrong ref', async () => {
|
|
654
761
|
await createTestEntities();
|
|
762
|
+
// Testing wrong reference...
|
|
655
763
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', (0, guid_1.guid)()] });
|
|
656
764
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
657
765
|
});
|
|
658
766
|
it('nonexistent ref', async () => {
|
|
659
767
|
await createTestEntities();
|
|
768
|
+
// Testing non-existent reference...
|
|
660
769
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['pickle', refGuid] });
|
|
661
770
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
662
771
|
});
|
|
663
772
|
it('inclusive ref', async () => {
|
|
664
773
|
await createTestEntities();
|
|
774
|
+
// Retrieving entity by inclusive reference...
|
|
665
775
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
666
776
|
type: '|',
|
|
667
777
|
ref: [
|
|
@@ -673,6 +783,7 @@ These hats are absolutely fantastic.`;
|
|
|
673
783
|
});
|
|
674
784
|
it('wrong inclusive ref', async () => {
|
|
675
785
|
await createTestEntities();
|
|
786
|
+
// Testing wrong inclusive reference...
|
|
676
787
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
677
788
|
type: '|',
|
|
678
789
|
ref: [
|
|
@@ -684,11 +795,13 @@ These hats are absolutely fantastic.`;
|
|
|
684
795
|
});
|
|
685
796
|
it('ref in an array', async () => {
|
|
686
797
|
await createTestEntities();
|
|
798
|
+
// Retrieving entity by array reference...
|
|
687
799
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['refArray', refGuid] });
|
|
688
800
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
689
801
|
});
|
|
690
802
|
it('wrong ref in an array', async () => {
|
|
691
803
|
await createTestEntities();
|
|
804
|
+
// Testing wrong array reference...
|
|
692
805
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
693
806
|
type: '&',
|
|
694
807
|
ref: [
|
|
@@ -700,6 +813,7 @@ These hats are absolutely fantastic.`;
|
|
|
700
813
|
});
|
|
701
814
|
it('logic operations', async () => {
|
|
702
815
|
await createTestEntities();
|
|
816
|
+
// Testing logic operations...
|
|
703
817
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
704
818
|
type: '&',
|
|
705
819
|
'!ref': [
|
|
@@ -737,6 +851,7 @@ These hats are absolutely fantastic.`;
|
|
|
737
851
|
it('count return', async () => {
|
|
738
852
|
await createTestEntities();
|
|
739
853
|
const result = await nymph.getEntities({ class: TestModel });
|
|
854
|
+
// Testing count return...
|
|
740
855
|
const resultCount = await nymph.getEntities({
|
|
741
856
|
class: TestModel,
|
|
742
857
|
return: 'count',
|
|
@@ -744,25 +859,30 @@ These hats are absolutely fantastic.`;
|
|
|
744
859
|
expect(resultCount).toBeGreaterThanOrEqual(1);
|
|
745
860
|
expect(resultCount).toEqual(result.length);
|
|
746
861
|
const resultSelectors = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', refGuid] });
|
|
862
|
+
// Testing count return with selectors...
|
|
747
863
|
const resultSelectorsCount = await nymph.getEntities({ class: TestModel, return: 'count' }, { type: '&', ref: ['reference', refGuid] });
|
|
748
864
|
expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
|
|
749
865
|
expect(resultSelectorsCount).toEqual(resultSelectors.length);
|
|
866
|
+
// Testing count return with limit...
|
|
750
867
|
const resultSelectorsLimit = await nymph.getEntities({
|
|
751
868
|
class: TestModel,
|
|
752
869
|
limit: 1,
|
|
753
870
|
return: 'count',
|
|
754
871
|
});
|
|
755
872
|
expect(resultSelectorsLimit).toEqual(1);
|
|
873
|
+
// Testing count return with limit...
|
|
756
874
|
const resultSelectorsSingle = await nymph.getEntity({
|
|
757
875
|
class: TestModel,
|
|
758
876
|
return: 'count',
|
|
759
877
|
});
|
|
760
878
|
expect(resultSelectorsSingle).toEqual(1);
|
|
879
|
+
// Testing empty count...
|
|
761
880
|
const resultSelectorsEmpty = await nymph.getEntities({ class: TestModel, return: 'count' }, { type: '&', ref: ['reference', (0, guid_1.guid)()] });
|
|
762
881
|
expect(resultSelectorsEmpty).toEqual(0);
|
|
763
882
|
});
|
|
764
883
|
it('guid return', async () => {
|
|
765
884
|
await createTestEntities();
|
|
885
|
+
// Testing guid return using logic operations...
|
|
766
886
|
const resultGuid = await nymph.getEntities({ class: TestModel, return: 'guid' }, {
|
|
767
887
|
type: '&',
|
|
768
888
|
'!ref': [
|
|
@@ -799,6 +919,7 @@ These hats are absolutely fantastic.`;
|
|
|
799
919
|
});
|
|
800
920
|
it('deep selector', async () => {
|
|
801
921
|
await createTestEntities();
|
|
922
|
+
// Testing deep selectors...
|
|
802
923
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
803
924
|
type: '&',
|
|
804
925
|
'!ref': [
|
|
@@ -911,6 +1032,7 @@ These hats are absolutely fantastic.`;
|
|
|
911
1032
|
expect(testEntity.$inArray(resultEntity4)).toEqual(true);
|
|
912
1033
|
});
|
|
913
1034
|
it('wrong deep selector', async () => {
|
|
1035
|
+
// Testing wrong deep selectors...
|
|
914
1036
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
915
1037
|
type: '&',
|
|
916
1038
|
selector: [
|
|
@@ -926,6 +1048,7 @@ These hats are absolutely fantastic.`;
|
|
|
926
1048
|
});
|
|
927
1049
|
it('qref', async () => {
|
|
928
1050
|
await createTestEntities();
|
|
1051
|
+
// Retrieving entity by qref...
|
|
929
1052
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
930
1053
|
type: '&',
|
|
931
1054
|
qref: [
|
|
@@ -937,6 +1060,7 @@ These hats are absolutely fantastic.`;
|
|
|
937
1060
|
});
|
|
938
1061
|
it('not qref', async () => {
|
|
939
1062
|
await createTestEntities();
|
|
1063
|
+
// Retrieving entity by !qref...
|
|
940
1064
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
941
1065
|
type: '&',
|
|
942
1066
|
'!qref': [
|
|
@@ -948,6 +1072,7 @@ These hats are absolutely fantastic.`;
|
|
|
948
1072
|
});
|
|
949
1073
|
it('wrong qref class', async () => {
|
|
950
1074
|
await createTestEntities();
|
|
1075
|
+
// Testing wrong qref...
|
|
951
1076
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
952
1077
|
type: '&',
|
|
953
1078
|
qref: [
|
|
@@ -959,6 +1084,7 @@ These hats are absolutely fantastic.`;
|
|
|
959
1084
|
});
|
|
960
1085
|
it('wrong qref data', async () => {
|
|
961
1086
|
await createTestEntities();
|
|
1087
|
+
// Testing wrong qref...
|
|
962
1088
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
963
1089
|
type: '&',
|
|
964
1090
|
qref: [
|
|
@@ -971,11 +1097,13 @@ These hats are absolutely fantastic.`;
|
|
|
971
1097
|
it('cdate and mdate sort option', async () => {
|
|
972
1098
|
await createMultipleTestEntities();
|
|
973
1099
|
for (const sort of ['cdate', 'mdate']) {
|
|
1100
|
+
// Retrieving entities sorted...
|
|
974
1101
|
let resultEntities = await nymph.getEntities({ class: TestModel, sort });
|
|
975
1102
|
expect(resultEntities.length).toBeGreaterThan(100);
|
|
976
1103
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
977
1104
|
expect(resultEntities[i + 1][sort]).toBeGreaterThan(resultEntities[i][sort] ?? 0);
|
|
978
1105
|
}
|
|
1106
|
+
// And test the same with guid return...
|
|
979
1107
|
let resultGuids = await nymph.getEntities({
|
|
980
1108
|
class: TestModel,
|
|
981
1109
|
sort,
|
|
@@ -985,6 +1113,7 @@ These hats are absolutely fantastic.`;
|
|
|
985
1113
|
for (let i = 0; i < resultGuids.length - 1; i++) {
|
|
986
1114
|
expect(resultGuids[i]).toEqual(resultEntities[i].guid);
|
|
987
1115
|
}
|
|
1116
|
+
// Retrieving entities reverse sorted...
|
|
988
1117
|
resultEntities = await nymph.getEntities({
|
|
989
1118
|
class: TestModel,
|
|
990
1119
|
sort,
|
|
@@ -994,11 +1123,14 @@ These hats are absolutely fantastic.`;
|
|
|
994
1123
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
995
1124
|
expect(resultEntities[i + 1][sort]).toBeLessThan(resultEntities[i][sort] ?? 0);
|
|
996
1125
|
}
|
|
1126
|
+
// And again with other selectors.
|
|
1127
|
+
// Retrieving entities sorted...
|
|
997
1128
|
resultEntities = await nymph.getEntities({ class: TestModel, sort }, { type: '&', match: ['name', '^Multi Test '] });
|
|
998
1129
|
expect(resultEntities.length).toEqual(100);
|
|
999
1130
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1000
1131
|
expect(resultEntities[i + 1][sort]).toBeGreaterThan(resultEntities[i][sort] ?? 0);
|
|
1001
1132
|
}
|
|
1133
|
+
// Retrieving entities reverse sorted...
|
|
1002
1134
|
resultEntities = await nymph.getEntities({ class: TestModel, sort, reverse: true }, { type: '&', match: ['name', '^Multi Test '] });
|
|
1003
1135
|
expect(resultEntities.length).toEqual(100);
|
|
1004
1136
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
@@ -1008,6 +1140,7 @@ These hats are absolutely fantastic.`;
|
|
|
1008
1140
|
});
|
|
1009
1141
|
it('property sort option', async () => {
|
|
1010
1142
|
await createMultipleTestEntities();
|
|
1143
|
+
// Retrieving entities sorted...
|
|
1011
1144
|
let resultEntities = await nymph.getEntities({
|
|
1012
1145
|
class: TestModel,
|
|
1013
1146
|
sort: 'number',
|
|
@@ -1016,6 +1149,7 @@ These hats are absolutely fantastic.`;
|
|
|
1016
1149
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1017
1150
|
expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThanOrEqual(resultEntities[i].number ?? 0);
|
|
1018
1151
|
}
|
|
1152
|
+
// And test the same with guid return...
|
|
1019
1153
|
let resultGuids = await nymph.getEntities({
|
|
1020
1154
|
class: TestModel,
|
|
1021
1155
|
sort: 'number',
|
|
@@ -1025,6 +1159,7 @@ These hats are absolutely fantastic.`;
|
|
|
1025
1159
|
for (let i = 0; i < resultGuids.length - 1; i++) {
|
|
1026
1160
|
expect(resultGuids[i]).toEqual(resultEntities[i].guid);
|
|
1027
1161
|
}
|
|
1162
|
+
// Retrieving entities reverse sorted...
|
|
1028
1163
|
resultEntities = await nymph.getEntities({
|
|
1029
1164
|
class: TestModel,
|
|
1030
1165
|
sort: 'number',
|
|
@@ -1034,12 +1169,15 @@ These hats are absolutely fantastic.`;
|
|
|
1034
1169
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1035
1170
|
expect(resultEntities[i + 1].number ?? 0).toBeLessThanOrEqual(resultEntities[i].number ?? Infinity);
|
|
1036
1171
|
}
|
|
1172
|
+
// And again with other selectors.
|
|
1173
|
+
// Retrieving entities sorted...
|
|
1037
1174
|
resultEntities = await nymph.getEntities({ class: TestModel, sort: 'number' }, { type: '&', match: ['name', '^Multi Test '] });
|
|
1038
1175
|
expect(resultEntities.length).toEqual(100);
|
|
1039
1176
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1040
1177
|
expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThan(resultEntities[i].number ?? 0);
|
|
1041
1178
|
expect(resultEntities[i].name).toEqual(`Multi Test ${100 - (resultEntities[i].number ?? 0)}`);
|
|
1042
1179
|
}
|
|
1180
|
+
// Retrieving entities reverse sorted...
|
|
1043
1181
|
resultEntities = await nymph.getEntities({ class: TestModel, sort: 'number', reverse: true }, { type: '&', match: ['name', '^Multi Test '] });
|
|
1044
1182
|
expect(resultEntities.length).toEqual(100);
|
|
1045
1183
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
@@ -1049,6 +1187,7 @@ These hats are absolutely fantastic.`;
|
|
|
1049
1187
|
});
|
|
1050
1188
|
it('delete reference', async () => {
|
|
1051
1189
|
await createTestEntities();
|
|
1190
|
+
// Deleting referenced entities...
|
|
1052
1191
|
await testEntity.reference?.$wake();
|
|
1053
1192
|
expect(await testEntity.reference?.$delete()).toEqual(true);
|
|
1054
1193
|
await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
|
|
@@ -1056,6 +1195,7 @@ These hats are absolutely fantastic.`;
|
|
|
1056
1195
|
});
|
|
1057
1196
|
it('delete', async () => {
|
|
1058
1197
|
await createTestEntities();
|
|
1198
|
+
// Deleting entity...
|
|
1059
1199
|
expect(await testEntity.$delete()).toEqual(true);
|
|
1060
1200
|
expect(testEntity.guid).toBeNull();
|
|
1061
1201
|
const entity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid });
|
|
@@ -1150,7 +1290,9 @@ function ExportImportTest(nymph, it) {
|
|
|
1150
1290
|
expect(await nymph.newUID('TestUID2')).toEqual(1);
|
|
1151
1291
|
for (let i = 0; i < 20; i++) {
|
|
1152
1292
|
const EntityClass = i < 15 ? TestModel : TestBModel;
|
|
1293
|
+
// Creating entity...
|
|
1153
1294
|
const testEntity = await EntityClass.factory();
|
|
1295
|
+
// Saving entity...
|
|
1154
1296
|
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1155
1297
|
testEntity.null = null;
|
|
1156
1298
|
testEntity.string = 'test';
|