@nymphjs/nymph 1.0.0-beta.5 → 1.0.0-beta.7
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 +16 -0
- package/dist/Entity.test.js +3 -1
- package/dist/Entity.test.js.map +1 -1
- package/dist/Entity.types.d.ts +1 -1
- package/dist/Nymph.d.ts +1 -1
- package/dist/Nymph.js +12 -12
- package/dist/Nymph.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +1 -0
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/testArtifacts.js +147 -149
- package/dist/driver/testArtifacts.js.map +1 -1
- package/package.json +7 -7
- package/src/Entity.test.ts +4 -1
- package/src/Entity.types.ts +1 -1
- package/src/Nymph.ts +40 -15
- package/src/driver/NymphDriver.ts +16 -0
- package/src/driver/testArtifacts.ts +14 -13
|
@@ -9,8 +9,8 @@ const strtotime_1 = __importDefault(require("locutus/php/datetime/strtotime"));
|
|
|
9
9
|
const guid_1 = require("@nymphjs/guid");
|
|
10
10
|
const testArtifacts_1 = require("../testArtifacts");
|
|
11
11
|
function QueriesTest(nymph, it) {
|
|
12
|
-
nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
13
|
-
nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
12
|
+
const TestModel = nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
13
|
+
const TestBModel = nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
14
14
|
let testEntity;
|
|
15
15
|
let testGuid;
|
|
16
16
|
let refGuid;
|
|
@@ -19,7 +19,7 @@ function QueriesTest(nymph, it) {
|
|
|
19
19
|
if (testGuid != null) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
testEntity = await
|
|
22
|
+
testEntity = await TestModel.factory();
|
|
23
23
|
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
24
24
|
testEntity.null = null;
|
|
25
25
|
testEntity.string = 'test';
|
|
@@ -35,7 +35,7 @@ This one's zip code is 92064.`;
|
|
|
35
35
|
expect(await testEntity.$save()).toEqual(true);
|
|
36
36
|
expect(testEntity.guid).not.toBeNull();
|
|
37
37
|
testGuid = testEntity.guid;
|
|
38
|
-
const entityReferenceTest = new
|
|
38
|
+
const entityReferenceTest = new TestModel();
|
|
39
39
|
entityReferenceTest.string = 'wrong';
|
|
40
40
|
entityReferenceTest.timestamp = (0, strtotime_1.default)('-2 days') * 1000;
|
|
41
41
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
@@ -45,18 +45,18 @@ This one's zip code is 92064.`;
|
|
|
45
45
|
expect(await testEntity.$save()).toEqual(true);
|
|
46
46
|
entityReferenceTest.test = 'good';
|
|
47
47
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
48
|
-
testEntity = nymph.driver.getEntitySync({ class:
|
|
49
|
-
expect(testEntity).toBeInstanceOf(
|
|
48
|
+
testEntity = nymph.driver.getEntitySync({ class: TestModel }, testGuid);
|
|
49
|
+
expect(testEntity).toBeInstanceOf(TestModel);
|
|
50
50
|
expect(testEntity.guid).toEqual(testGuid);
|
|
51
|
-
testEntity = (await nymph.getEntity({ class:
|
|
52
|
-
expect(testEntity).toBeInstanceOf(
|
|
51
|
+
testEntity = (await nymph.getEntity({ class: TestModel }, testGuid));
|
|
52
|
+
expect(testEntity).toBeInstanceOf(TestModel);
|
|
53
53
|
expect(testEntity.guid).toEqual(testGuid);
|
|
54
54
|
}
|
|
55
55
|
async function createMultipleTestEntities() {
|
|
56
56
|
if (!createdMultiple) {
|
|
57
57
|
createdMultiple = true;
|
|
58
58
|
for (let i = 0; i < 100; i++) {
|
|
59
|
-
const testEntity = await
|
|
59
|
+
const testEntity = await TestModel.factory();
|
|
60
60
|
testEntity.name = `Multi Test ${i}`;
|
|
61
61
|
testEntity.$removeTag('test');
|
|
62
62
|
testEntity.$addTag('multiTest');
|
|
@@ -66,12 +66,12 @@ This one's zip code is 92064.`;
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
it('delete old test data', async () => {
|
|
69
|
-
let all = await nymph.getEntities({ class:
|
|
69
|
+
let all = await nymph.getEntities({ class: TestModel });
|
|
70
70
|
expect(Array.isArray(all)).toEqual(true);
|
|
71
71
|
for (const cur of all) {
|
|
72
72
|
expect(await cur.$delete()).toEqual(true);
|
|
73
73
|
}
|
|
74
|
-
all = await nymph.getEntities({ class:
|
|
74
|
+
all = await nymph.getEntities({ class: TestModel });
|
|
75
75
|
expect(all.length).toEqual(0);
|
|
76
76
|
});
|
|
77
77
|
it('create entity', async () => {
|
|
@@ -89,11 +89,11 @@ This one's zip code is 92064.`;
|
|
|
89
89
|
});
|
|
90
90
|
it('by guid', async () => {
|
|
91
91
|
await createTestEntities();
|
|
92
|
-
let resultEntity = await nymph.getEntity({ class:
|
|
92
|
+
let resultEntity = await nymph.getEntity({ class: TestModel }, testGuid);
|
|
93
93
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
94
|
-
resultEntity = await
|
|
94
|
+
resultEntity = await TestModel.factory(testGuid);
|
|
95
95
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
96
|
-
resultEntity = await nymph.getEntity({ class:
|
|
96
|
+
resultEntity = await nymph.getEntity({ class: TestModel }, (0, guid_1.guid)());
|
|
97
97
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
98
98
|
});
|
|
99
99
|
it('transactions', async () => {
|
|
@@ -116,11 +116,11 @@ This one's zip code is 92064.`;
|
|
|
116
116
|
testEntity.$nymph = transaction;
|
|
117
117
|
expect(await transaction.inTransaction()).toEqual(true);
|
|
118
118
|
expect(await testEntity.$delete()).toEqual(true);
|
|
119
|
-
const resultEntity = await transaction.getEntity({ class:
|
|
119
|
+
const resultEntity = await transaction.getEntity({ class: TestModel }, testGuid);
|
|
120
120
|
expect(resultEntity).toBeNull();
|
|
121
121
|
await transaction.rollback('test');
|
|
122
122
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
123
|
-
testEntity = (await transaction.getEntity({ class:
|
|
123
|
+
testEntity = (await transaction.getEntity({ class: TestModel }, testGuid));
|
|
124
124
|
expect(testEntity.guid).toEqual(testGuid);
|
|
125
125
|
transaction = await nymph.startTransaction('test');
|
|
126
126
|
testEntity.$nymph = transaction;
|
|
@@ -138,7 +138,7 @@ This one's zip code is 92064.`;
|
|
|
138
138
|
it('options', async () => {
|
|
139
139
|
await createTestEntities();
|
|
140
140
|
const resultEntities = await nymph.getEntities({
|
|
141
|
-
class:
|
|
141
|
+
class: TestModel,
|
|
142
142
|
reverse: true,
|
|
143
143
|
offset: 1,
|
|
144
144
|
limit: 1,
|
|
@@ -149,174 +149,174 @@ This one's zip code is 92064.`;
|
|
|
149
149
|
});
|
|
150
150
|
it('guid and tags', async () => {
|
|
151
151
|
await createTestEntities();
|
|
152
|
-
const resultEntity = await nymph.getEntity({ class:
|
|
152
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid, tag: 'test' });
|
|
153
153
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
154
154
|
});
|
|
155
155
|
it('or selector', async () => {
|
|
156
156
|
await createTestEntities();
|
|
157
|
-
const resultEntity = await nymph.getEntity({ class:
|
|
157
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '|', guid: [testGuid, (0, guid_1.guid)()] });
|
|
158
158
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
159
159
|
});
|
|
160
160
|
it('wrong or selector', async () => {
|
|
161
161
|
await createTestEntities();
|
|
162
|
-
const resultEntity = await nymph.getEntity({ class:
|
|
162
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '|', guid: [(0, guid_1.guid)(), (0, guid_1.guid)()] });
|
|
163
163
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
164
164
|
});
|
|
165
165
|
it('not guid', async () => {
|
|
166
166
|
await createTestEntities();
|
|
167
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
167
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', '!guid': (0, guid_1.guid)(), tag: 'test' });
|
|
168
168
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
169
169
|
});
|
|
170
170
|
it('not tags', async () => {
|
|
171
171
|
await createTestEntities();
|
|
172
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
172
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] });
|
|
173
173
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
174
174
|
});
|
|
175
175
|
it('guid and wrong tags', async () => {
|
|
176
176
|
await createTestEntities();
|
|
177
|
-
const resultEntity = await nymph.getEntity({ class:
|
|
177
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid, tag: ['pickles'] });
|
|
178
178
|
expect(resultEntity).toBeNull();
|
|
179
179
|
});
|
|
180
180
|
it('tags', async () => {
|
|
181
181
|
await createTestEntities();
|
|
182
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
182
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' });
|
|
183
183
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
184
184
|
});
|
|
185
185
|
it('wrong tags', async () => {
|
|
186
186
|
await createTestEntities();
|
|
187
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
187
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles' });
|
|
188
188
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
189
189
|
});
|
|
190
190
|
it('inclusive tags', async () => {
|
|
191
191
|
await createTestEntities();
|
|
192
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
192
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '|', tag: ['pickles', 'test', 'barbecue'] });
|
|
193
193
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
194
194
|
});
|
|
195
195
|
it('wrong inclusive tags', async () => {
|
|
196
196
|
await createTestEntities();
|
|
197
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
197
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '|', tag: ['pickles', 'barbecue'] });
|
|
198
198
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
199
199
|
});
|
|
200
200
|
it('mixed tags', async () => {
|
|
201
201
|
await createTestEntities();
|
|
202
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
202
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', tag: ['pickles', 'test', 'barbecue'] });
|
|
203
203
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
204
204
|
});
|
|
205
205
|
it('wrong inclusive mixed tags', async () => {
|
|
206
206
|
await createTestEntities();
|
|
207
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
207
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', tag: ['pickles', 'barbecue'] });
|
|
208
208
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
209
209
|
});
|
|
210
210
|
it('wrong exclusive mixed tags', async () => {
|
|
211
211
|
await createTestEntities();
|
|
212
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
212
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles' }, { type: '|', tag: ['test', 'barbecue'] });
|
|
213
213
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
214
214
|
});
|
|
215
215
|
it('defined', async () => {
|
|
216
216
|
await createTestEntities();
|
|
217
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
217
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', defined: 'string' });
|
|
218
218
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
219
219
|
});
|
|
220
220
|
it('not defined', async () => {
|
|
221
221
|
await createTestEntities();
|
|
222
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
222
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!defined': 'pickles' });
|
|
223
223
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
224
224
|
});
|
|
225
225
|
it('defined in a not and clause', async () => {
|
|
226
226
|
await createTestEntities();
|
|
227
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
227
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '!&', defined: 'pickles' }, { type: '&', tag: 'test' });
|
|
228
228
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
229
229
|
});
|
|
230
230
|
it('equal', async () => {
|
|
231
231
|
await createTestEntities();
|
|
232
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
232
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', equal: ['string', 'test'] });
|
|
233
233
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
234
234
|
});
|
|
235
235
|
it('not equal', async () => {
|
|
236
236
|
await createTestEntities();
|
|
237
|
-
const referenceEntity = await
|
|
237
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
238
238
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
239
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
239
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!equal': ['string', 'wrong'] });
|
|
240
240
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
241
241
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
242
242
|
});
|
|
243
243
|
it('like', async () => {
|
|
244
244
|
await createTestEntities();
|
|
245
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
245
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', like: ['string', 't_s%'] });
|
|
246
246
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
247
247
|
});
|
|
248
248
|
it('not like', async () => {
|
|
249
249
|
await createTestEntities();
|
|
250
|
-
const referenceEntity = await
|
|
250
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
251
251
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
252
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
252
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!like': ['string', 'wr_n%'] });
|
|
253
253
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
254
254
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
255
255
|
});
|
|
256
256
|
it('ilike', async () => {
|
|
257
257
|
await createTestEntities();
|
|
258
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
258
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ilike: ['string', 'T_s%'] });
|
|
259
259
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
260
260
|
});
|
|
261
261
|
it('not ilike', async () => {
|
|
262
262
|
await createTestEntities();
|
|
263
|
-
const referenceEntity = await
|
|
263
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
264
264
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
265
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
265
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] });
|
|
266
266
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
267
267
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
268
268
|
});
|
|
269
269
|
it('like with wrong case', async () => {
|
|
270
270
|
await createTestEntities();
|
|
271
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
271
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', like: ['string', 'T_s%'] });
|
|
272
272
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
273
273
|
});
|
|
274
274
|
it('tags and equal', async () => {
|
|
275
275
|
await createTestEntities();
|
|
276
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
276
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', equal: ['string', 'test'] });
|
|
277
277
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
278
278
|
});
|
|
279
279
|
it('wrong tags right equal', async () => {
|
|
280
280
|
await createTestEntities();
|
|
281
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
281
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles', equal: ['string', 'test'] });
|
|
282
282
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
283
283
|
});
|
|
284
284
|
it('right tags wrong equal', async () => {
|
|
285
285
|
await createTestEntities();
|
|
286
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
286
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', equal: ['string', 'pickles'] });
|
|
287
287
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
288
288
|
});
|
|
289
289
|
it('wrong tags wrong equal', async () => {
|
|
290
290
|
await createTestEntities();
|
|
291
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
291
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles', equal: ['string', 'pickles'] });
|
|
292
292
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
293
293
|
});
|
|
294
294
|
it('contain', async () => {
|
|
295
295
|
await createTestEntities();
|
|
296
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
296
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 'values'] });
|
|
297
297
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
298
|
-
resultEntity = await nymph.getEntities({ class:
|
|
298
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['string', 'test'] });
|
|
299
299
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
300
300
|
});
|
|
301
301
|
it('not contain', async () => {
|
|
302
302
|
await createTestEntities();
|
|
303
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
303
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', contain: ['array', 'pickles'] });
|
|
304
304
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
305
305
|
});
|
|
306
306
|
it('wrong contain', async () => {
|
|
307
307
|
await createTestEntities();
|
|
308
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
308
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 'pickles'] });
|
|
309
309
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
310
|
-
resultEntity = await nymph.getEntities({ class:
|
|
310
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['string', 'pickles'] });
|
|
311
311
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
312
312
|
});
|
|
313
313
|
it('match', async () => {
|
|
314
314
|
await createTestEntities();
|
|
315
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
315
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', match: ['match', '.*'] });
|
|
316
316
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
317
|
-
resultEntity = await nymph.getEntities({ class:
|
|
317
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', match: ['match', 'Edward McCheese'] });
|
|
318
318
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
319
|
-
resultEntity = await nymph.getEntities({ class:
|
|
319
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, {
|
|
320
320
|
type: '|',
|
|
321
321
|
match: [
|
|
322
322
|
['string', '[0-9]'],
|
|
@@ -324,13 +324,13 @@ This one's zip code is 92064.`;
|
|
|
324
324
|
],
|
|
325
325
|
});
|
|
326
326
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
327
|
-
resultEntity = await nymph.getEntities({ class:
|
|
327
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
328
328
|
type: '&',
|
|
329
329
|
tag: 'test',
|
|
330
330
|
match: ['match', '[-a-zA-Z0-9+_]+@[-a-zA-Z0-9_]+.[-a-zA-Z0-9_]{2,4}'],
|
|
331
331
|
});
|
|
332
332
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
333
|
-
resultEntity = await nymph.getEntities({ class:
|
|
333
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
334
334
|
type: '&',
|
|
335
335
|
tag: 'test',
|
|
336
336
|
match: ['match', '\\([0-9]{3}\\) [0-9]{3}-[0-9]{4}'],
|
|
@@ -339,16 +339,16 @@ This one's zip code is 92064.`;
|
|
|
339
339
|
});
|
|
340
340
|
it('imatch', async () => {
|
|
341
341
|
await createTestEntities();
|
|
342
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
342
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] });
|
|
343
343
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
344
344
|
});
|
|
345
345
|
it('wrong match', async () => {
|
|
346
346
|
await createTestEntities();
|
|
347
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
347
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', match: ['match', 'Q'] });
|
|
348
348
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
349
|
-
resultEntity = await nymph.getEntities({ class:
|
|
349
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickle', match: ['match', '.*'] });
|
|
350
350
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
351
|
-
resultEntity = await nymph.getEntities({ class:
|
|
351
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
352
352
|
type: '|',
|
|
353
353
|
match: [
|
|
354
354
|
['string', '[0-9]'],
|
|
@@ -359,17 +359,17 @@ This one's zip code is 92064.`;
|
|
|
359
359
|
});
|
|
360
360
|
it('match wrong case', async () => {
|
|
361
361
|
await createTestEntities();
|
|
362
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
362
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', match: ['match', 'edward mccheese'] });
|
|
363
363
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
364
364
|
});
|
|
365
365
|
it('match and equal inclusive', async () => {
|
|
366
366
|
await createTestEntities();
|
|
367
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
367
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', equal: ['string', 'pickles'], match: ['string', 'test'] });
|
|
368
368
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
369
369
|
});
|
|
370
370
|
it('greater than', async () => {
|
|
371
371
|
await createTestEntities();
|
|
372
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
372
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
373
373
|
type: '|',
|
|
374
374
|
gt: [
|
|
375
375
|
['number', 30],
|
|
@@ -377,7 +377,7 @@ This one's zip code is 92064.`;
|
|
|
377
377
|
],
|
|
378
378
|
});
|
|
379
379
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
380
|
-
resultEntity = await nymph.getEntities({ class:
|
|
380
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
381
381
|
type: '|',
|
|
382
382
|
gt: [
|
|
383
383
|
['number', 31],
|
|
@@ -385,7 +385,7 @@ This one's zip code is 92064.`;
|
|
|
385
385
|
],
|
|
386
386
|
});
|
|
387
387
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
388
|
-
resultEntity = await nymph.getEntities({ class:
|
|
388
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
389
389
|
type: '|',
|
|
390
390
|
gt: [
|
|
391
391
|
['number', 29],
|
|
@@ -393,7 +393,7 @@ This one's zip code is 92064.`;
|
|
|
393
393
|
],
|
|
394
394
|
});
|
|
395
395
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
396
|
-
resultEntity = await nymph.getEntities({ class:
|
|
396
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
397
397
|
type: '|',
|
|
398
398
|
gt: [
|
|
399
399
|
['numberString', 30],
|
|
@@ -401,7 +401,7 @@ This one's zip code is 92064.`;
|
|
|
401
401
|
],
|
|
402
402
|
});
|
|
403
403
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
404
|
-
resultEntity = await nymph.getEntities({ class:
|
|
404
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
405
405
|
type: '|',
|
|
406
406
|
gt: [
|
|
407
407
|
['numberString', 31],
|
|
@@ -409,7 +409,7 @@ This one's zip code is 92064.`;
|
|
|
409
409
|
],
|
|
410
410
|
});
|
|
411
411
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
412
|
-
resultEntity = await nymph.getEntities({ class:
|
|
412
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
413
413
|
type: '|',
|
|
414
414
|
gt: [
|
|
415
415
|
['numberString', 29],
|
|
@@ -420,7 +420,7 @@ This one's zip code is 92064.`;
|
|
|
420
420
|
});
|
|
421
421
|
it('greater than or equal', async () => {
|
|
422
422
|
await createTestEntities();
|
|
423
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
423
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
424
424
|
type: '|',
|
|
425
425
|
gte: [
|
|
426
426
|
['number', 30],
|
|
@@ -428,7 +428,7 @@ This one's zip code is 92064.`;
|
|
|
428
428
|
],
|
|
429
429
|
});
|
|
430
430
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
431
|
-
resultEntity = await nymph.getEntities({ class:
|
|
431
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
432
432
|
type: '|',
|
|
433
433
|
gte: [
|
|
434
434
|
['number', 31],
|
|
@@ -436,7 +436,7 @@ This one's zip code is 92064.`;
|
|
|
436
436
|
],
|
|
437
437
|
});
|
|
438
438
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
439
|
-
resultEntity = await nymph.getEntities({ class:
|
|
439
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
440
440
|
type: '|',
|
|
441
441
|
gte: [
|
|
442
442
|
['number', 29],
|
|
@@ -444,7 +444,7 @@ This one's zip code is 92064.`;
|
|
|
444
444
|
],
|
|
445
445
|
});
|
|
446
446
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
447
|
-
resultEntity = await nymph.getEntities({ class:
|
|
447
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
448
448
|
type: '|',
|
|
449
449
|
gte: [
|
|
450
450
|
['numberString', 30],
|
|
@@ -452,7 +452,7 @@ This one's zip code is 92064.`;
|
|
|
452
452
|
],
|
|
453
453
|
});
|
|
454
454
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
455
|
-
resultEntity = await nymph.getEntities({ class:
|
|
455
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
456
456
|
type: '|',
|
|
457
457
|
gte: [
|
|
458
458
|
['numberString', 31],
|
|
@@ -460,7 +460,7 @@ This one's zip code is 92064.`;
|
|
|
460
460
|
],
|
|
461
461
|
});
|
|
462
462
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
463
|
-
resultEntity = await nymph.getEntities({ class:
|
|
463
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
464
464
|
type: '|',
|
|
465
465
|
gte: [
|
|
466
466
|
['numberString', 29],
|
|
@@ -471,7 +471,7 @@ This one's zip code is 92064.`;
|
|
|
471
471
|
});
|
|
472
472
|
it('less than', async () => {
|
|
473
473
|
await createTestEntities();
|
|
474
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
474
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
475
475
|
type: '|',
|
|
476
476
|
lt: [
|
|
477
477
|
['number', 30],
|
|
@@ -479,7 +479,7 @@ This one's zip code is 92064.`;
|
|
|
479
479
|
],
|
|
480
480
|
});
|
|
481
481
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
482
|
-
resultEntity = await nymph.getEntities({ class:
|
|
482
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
483
483
|
type: '|',
|
|
484
484
|
lt: [
|
|
485
485
|
['number', 31],
|
|
@@ -487,7 +487,7 @@ This one's zip code is 92064.`;
|
|
|
487
487
|
],
|
|
488
488
|
});
|
|
489
489
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
490
|
-
resultEntity = await nymph.getEntities({ class:
|
|
490
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
491
491
|
type: '|',
|
|
492
492
|
lt: [
|
|
493
493
|
['number', 29],
|
|
@@ -495,7 +495,7 @@ This one's zip code is 92064.`;
|
|
|
495
495
|
],
|
|
496
496
|
});
|
|
497
497
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
498
|
-
resultEntity = await nymph.getEntities({ class:
|
|
498
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
499
499
|
type: '|',
|
|
500
500
|
lt: [
|
|
501
501
|
['numberString', 30],
|
|
@@ -503,7 +503,7 @@ This one's zip code is 92064.`;
|
|
|
503
503
|
],
|
|
504
504
|
});
|
|
505
505
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
506
|
-
resultEntity = await nymph.getEntities({ class:
|
|
506
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
507
507
|
type: '|',
|
|
508
508
|
lt: [
|
|
509
509
|
['numberString', 31],
|
|
@@ -511,7 +511,7 @@ This one's zip code is 92064.`;
|
|
|
511
511
|
],
|
|
512
512
|
});
|
|
513
513
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
514
|
-
resultEntity = await nymph.getEntities({ class:
|
|
514
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
515
515
|
type: '|',
|
|
516
516
|
lt: [
|
|
517
517
|
['numberString', 29],
|
|
@@ -522,7 +522,7 @@ This one's zip code is 92064.`;
|
|
|
522
522
|
});
|
|
523
523
|
it('less than or equal', async () => {
|
|
524
524
|
await createTestEntities();
|
|
525
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
525
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
526
526
|
type: '|',
|
|
527
527
|
lte: [
|
|
528
528
|
['number', 30],
|
|
@@ -530,7 +530,7 @@ This one's zip code is 92064.`;
|
|
|
530
530
|
],
|
|
531
531
|
});
|
|
532
532
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
533
|
-
resultEntity = await nymph.getEntities({ class:
|
|
533
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
534
534
|
type: '|',
|
|
535
535
|
lte: [
|
|
536
536
|
['number', 31],
|
|
@@ -538,7 +538,7 @@ This one's zip code is 92064.`;
|
|
|
538
538
|
],
|
|
539
539
|
});
|
|
540
540
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
541
|
-
resultEntity = await nymph.getEntities({ class:
|
|
541
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
542
542
|
type: '|',
|
|
543
543
|
lte: [
|
|
544
544
|
['number', 29],
|
|
@@ -546,7 +546,7 @@ This one's zip code is 92064.`;
|
|
|
546
546
|
],
|
|
547
547
|
});
|
|
548
548
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
549
|
-
resultEntity = await nymph.getEntities({ class:
|
|
549
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
550
550
|
type: '|',
|
|
551
551
|
lte: [
|
|
552
552
|
['numberString', 30],
|
|
@@ -554,7 +554,7 @@ This one's zip code is 92064.`;
|
|
|
554
554
|
],
|
|
555
555
|
});
|
|
556
556
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
557
|
-
resultEntity = await nymph.getEntities({ class:
|
|
557
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
558
558
|
type: '|',
|
|
559
559
|
lte: [
|
|
560
560
|
['numberString', 31],
|
|
@@ -562,7 +562,7 @@ This one's zip code is 92064.`;
|
|
|
562
562
|
],
|
|
563
563
|
});
|
|
564
564
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
565
|
-
resultEntity = await nymph.getEntities({ class:
|
|
565
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
566
566
|
type: '|',
|
|
567
567
|
lte: [
|
|
568
568
|
['numberString', 29],
|
|
@@ -573,31 +573,31 @@ This one's zip code is 92064.`;
|
|
|
573
573
|
});
|
|
574
574
|
it('not inequality', async () => {
|
|
575
575
|
await createTestEntities();
|
|
576
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
576
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', gte: ['number', 60] });
|
|
577
577
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
578
578
|
});
|
|
579
579
|
it('wrong inequality', async () => {
|
|
580
580
|
await createTestEntities();
|
|
581
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
581
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', lte: ['number', 29.99] });
|
|
582
582
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
583
583
|
});
|
|
584
584
|
it('greater than cdate', async () => {
|
|
585
585
|
await createTestEntities();
|
|
586
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
586
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] });
|
|
587
587
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
588
588
|
});
|
|
589
589
|
it('wrong cdate', async () => {
|
|
590
590
|
await createTestEntities();
|
|
591
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
591
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] });
|
|
592
592
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
593
593
|
});
|
|
594
594
|
it('time selector', async () => {
|
|
595
595
|
await createTestEntities();
|
|
596
|
-
const referenceEntity = await
|
|
597
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
596
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
597
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['timestamp', null, '-1 day'] });
|
|
598
598
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
599
599
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
600
|
-
resultEntity = await nymph.getEntities({ class:
|
|
600
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
601
601
|
type: '|',
|
|
602
602
|
gt: [
|
|
603
603
|
['timestamp', null, '-1 day'],
|
|
@@ -606,23 +606,23 @@ This one's zip code is 92064.`;
|
|
|
606
606
|
});
|
|
607
607
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
608
608
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
609
|
-
resultEntity = await nymph.getEntities({ class:
|
|
609
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['timestamp', null, '-3 days'] });
|
|
610
610
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
611
611
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
612
|
-
resultEntity = await nymph.getEntities({ class:
|
|
612
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['cdate', null, '-1 day'] });
|
|
613
613
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
614
614
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
615
615
|
});
|
|
616
616
|
it('wrong time selector', async () => {
|
|
617
617
|
await createTestEntities();
|
|
618
|
-
const referenceEntity = await
|
|
619
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
618
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
619
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] });
|
|
620
620
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
621
621
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
622
|
-
resultEntity = await nymph.getEntities({ class:
|
|
622
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] });
|
|
623
623
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
624
624
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
625
|
-
resultEntity = await nymph.getEntities({ class:
|
|
625
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] });
|
|
626
626
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
627
627
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
628
628
|
});
|
|
@@ -633,27 +633,27 @@ This one's zip code is 92064.`;
|
|
|
633
633
|
});
|
|
634
634
|
it('ref', async () => {
|
|
635
635
|
await createTestEntities();
|
|
636
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
636
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', refGuid] });
|
|
637
637
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
638
638
|
});
|
|
639
639
|
it('not ref', async () => {
|
|
640
640
|
await createTestEntities();
|
|
641
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
641
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', ref: ['reference', (0, guid_1.guid)()] });
|
|
642
642
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
643
643
|
});
|
|
644
644
|
it('wrong ref', async () => {
|
|
645
645
|
await createTestEntities();
|
|
646
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
646
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', (0, guid_1.guid)()] });
|
|
647
647
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
648
648
|
});
|
|
649
649
|
it('nonexistent ref', async () => {
|
|
650
650
|
await createTestEntities();
|
|
651
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
651
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['pickle', refGuid] });
|
|
652
652
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
653
653
|
});
|
|
654
654
|
it('inclusive ref', async () => {
|
|
655
655
|
await createTestEntities();
|
|
656
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
656
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
657
657
|
type: '|',
|
|
658
658
|
ref: [
|
|
659
659
|
['reference', refGuid],
|
|
@@ -664,7 +664,7 @@ This one's zip code is 92064.`;
|
|
|
664
664
|
});
|
|
665
665
|
it('wrong inclusive ref', async () => {
|
|
666
666
|
await createTestEntities();
|
|
667
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
667
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
668
668
|
type: '|',
|
|
669
669
|
ref: [
|
|
670
670
|
['reference', (0, guid_1.guid)()],
|
|
@@ -675,12 +675,12 @@ This one's zip code is 92064.`;
|
|
|
675
675
|
});
|
|
676
676
|
it('ref in an array', async () => {
|
|
677
677
|
await createTestEntities();
|
|
678
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
678
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['refArray', refGuid] });
|
|
679
679
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
680
680
|
});
|
|
681
681
|
it('wrong ref in an array', async () => {
|
|
682
682
|
await createTestEntities();
|
|
683
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
683
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
684
684
|
type: '&',
|
|
685
685
|
ref: [
|
|
686
686
|
['refArray', refGuid],
|
|
@@ -691,7 +691,7 @@ This one's zip code is 92064.`;
|
|
|
691
691
|
});
|
|
692
692
|
it('logic operations', async () => {
|
|
693
693
|
await createTestEntities();
|
|
694
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
694
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
695
695
|
type: '&',
|
|
696
696
|
'!ref': [
|
|
697
697
|
['refArray', (0, guid_1.guid)()],
|
|
@@ -727,34 +727,34 @@ This one's zip code is 92064.`;
|
|
|
727
727
|
});
|
|
728
728
|
it('count return', async () => {
|
|
729
729
|
await createTestEntities();
|
|
730
|
-
const result = await nymph.getEntities({ class:
|
|
730
|
+
const result = await nymph.getEntities({ class: TestModel });
|
|
731
731
|
const resultCount = await nymph.getEntities({
|
|
732
|
-
class:
|
|
732
|
+
class: TestModel,
|
|
733
733
|
return: 'count',
|
|
734
734
|
});
|
|
735
735
|
expect(resultCount).toBeGreaterThanOrEqual(1);
|
|
736
736
|
expect(resultCount).toEqual(result.length);
|
|
737
|
-
const resultSelectors = await nymph.getEntities({ class:
|
|
738
|
-
const resultSelectorsCount = await nymph.getEntities({ class:
|
|
737
|
+
const resultSelectors = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', refGuid] });
|
|
738
|
+
const resultSelectorsCount = await nymph.getEntities({ class: TestModel, return: 'count' }, { type: '&', ref: ['reference', refGuid] });
|
|
739
739
|
expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
|
|
740
740
|
expect(resultSelectorsCount).toEqual(resultSelectors.length);
|
|
741
741
|
const resultSelectorsLimit = await nymph.getEntities({
|
|
742
|
-
class:
|
|
742
|
+
class: TestModel,
|
|
743
743
|
limit: 1,
|
|
744
744
|
return: 'count',
|
|
745
745
|
});
|
|
746
746
|
expect(resultSelectorsLimit).toEqual(1);
|
|
747
747
|
const resultSelectorsSingle = await nymph.getEntity({
|
|
748
|
-
class:
|
|
748
|
+
class: TestModel,
|
|
749
749
|
return: 'count',
|
|
750
750
|
});
|
|
751
751
|
expect(resultSelectorsSingle).toEqual(1);
|
|
752
|
-
const resultSelectorsEmpty = await nymph.getEntities({ class:
|
|
752
|
+
const resultSelectorsEmpty = await nymph.getEntities({ class: TestModel, return: 'count' }, { type: '&', ref: ['reference', (0, guid_1.guid)()] });
|
|
753
753
|
expect(resultSelectorsEmpty).toEqual(0);
|
|
754
754
|
});
|
|
755
755
|
it('guid return', async () => {
|
|
756
756
|
await createTestEntities();
|
|
757
|
-
const resultGuid = await nymph.getEntities({ class:
|
|
757
|
+
const resultGuid = await nymph.getEntities({ class: TestModel, return: 'guid' }, {
|
|
758
758
|
type: '&',
|
|
759
759
|
'!ref': [
|
|
760
760
|
['refArray', (0, guid_1.guid)()],
|
|
@@ -790,7 +790,7 @@ This one's zip code is 92064.`;
|
|
|
790
790
|
});
|
|
791
791
|
it('deep selector', async () => {
|
|
792
792
|
await createTestEntities();
|
|
793
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
793
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
794
794
|
type: '&',
|
|
795
795
|
'!ref': [
|
|
796
796
|
['refArray', (0, guid_1.guid)()],
|
|
@@ -830,7 +830,7 @@ This one's zip code is 92064.`;
|
|
|
830
830
|
],
|
|
831
831
|
});
|
|
832
832
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
833
|
-
const resultEntity2 = await nymph.getEntities({ class:
|
|
833
|
+
const resultEntity2 = await nymph.getEntities({ class: TestModel }, {
|
|
834
834
|
type: '&',
|
|
835
835
|
'!ref': [
|
|
836
836
|
['refArray', (0, guid_1.guid)()],
|
|
@@ -870,7 +870,7 @@ This one's zip code is 92064.`;
|
|
|
870
870
|
],
|
|
871
871
|
});
|
|
872
872
|
expect(testEntity.$inArray(resultEntity2)).toEqual(true);
|
|
873
|
-
const resultEntity3 = await nymph.getEntities({ class:
|
|
873
|
+
const resultEntity3 = await nymph.getEntities({ class: TestModel }, {
|
|
874
874
|
type: '|',
|
|
875
875
|
selector: [
|
|
876
876
|
{
|
|
@@ -882,7 +882,7 @@ This one's zip code is 92064.`;
|
|
|
882
882
|
],
|
|
883
883
|
});
|
|
884
884
|
expect(testEntity.$inArray(resultEntity3)).toEqual(true);
|
|
885
|
-
const resultEntity4 = await nymph.getEntities({ class:
|
|
885
|
+
const resultEntity4 = await nymph.getEntities({ class: TestModel }, {
|
|
886
886
|
type: '|',
|
|
887
887
|
selector: [
|
|
888
888
|
{
|
|
@@ -902,7 +902,7 @@ This one's zip code is 92064.`;
|
|
|
902
902
|
expect(testEntity.$inArray(resultEntity4)).toEqual(true);
|
|
903
903
|
});
|
|
904
904
|
it('wrong deep selector', async () => {
|
|
905
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
905
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
906
906
|
type: '&',
|
|
907
907
|
selector: [
|
|
908
908
|
{
|
|
@@ -917,44 +917,44 @@ This one's zip code is 92064.`;
|
|
|
917
917
|
});
|
|
918
918
|
it('qref', async () => {
|
|
919
919
|
await createTestEntities();
|
|
920
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
920
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
921
921
|
type: '&',
|
|
922
922
|
qref: [
|
|
923
923
|
'reference',
|
|
924
|
-
[{ class:
|
|
924
|
+
[{ class: TestModel }, { type: '&', equal: ['test', 'good'] }],
|
|
925
925
|
],
|
|
926
926
|
});
|
|
927
927
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
928
928
|
});
|
|
929
929
|
it('not qref', async () => {
|
|
930
930
|
await createTestEntities();
|
|
931
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
931
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
932
932
|
type: '&',
|
|
933
933
|
'!qref': [
|
|
934
934
|
'reference',
|
|
935
|
-
[{ class:
|
|
935
|
+
[{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
|
|
936
936
|
],
|
|
937
937
|
});
|
|
938
938
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
939
939
|
});
|
|
940
940
|
it('wrong qref class', async () => {
|
|
941
941
|
await createTestEntities();
|
|
942
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
942
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
943
943
|
type: '&',
|
|
944
944
|
qref: [
|
|
945
945
|
'reference',
|
|
946
|
-
[{ class:
|
|
946
|
+
[{ class: TestBModel }, { type: '&', equal: ['test', 'good'] }],
|
|
947
947
|
],
|
|
948
948
|
});
|
|
949
949
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
950
950
|
});
|
|
951
951
|
it('wrong qref data', async () => {
|
|
952
952
|
await createTestEntities();
|
|
953
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
953
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
954
954
|
type: '&',
|
|
955
955
|
qref: [
|
|
956
956
|
'reference',
|
|
957
|
-
[{ class:
|
|
957
|
+
[{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
|
|
958
958
|
],
|
|
959
959
|
});
|
|
960
960
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -963,7 +963,7 @@ This one's zip code is 92064.`;
|
|
|
963
963
|
await createMultipleTestEntities();
|
|
964
964
|
for (const sort of ['cdate', 'mdate']) {
|
|
965
965
|
let resultEntities = await nymph.getEntities({
|
|
966
|
-
class:
|
|
966
|
+
class: TestModel,
|
|
967
967
|
sort: sort,
|
|
968
968
|
});
|
|
969
969
|
expect(resultEntities.length).toBeGreaterThan(100);
|
|
@@ -971,7 +971,7 @@ This one's zip code is 92064.`;
|
|
|
971
971
|
expect(resultEntities[i + 1][sort]).toBeGreaterThan(resultEntities[i][sort] ?? 0);
|
|
972
972
|
}
|
|
973
973
|
let resultGuids = await nymph.getEntities({
|
|
974
|
-
class:
|
|
974
|
+
class: TestModel,
|
|
975
975
|
sort: sort,
|
|
976
976
|
return: 'guid',
|
|
977
977
|
});
|
|
@@ -980,7 +980,7 @@ This one's zip code is 92064.`;
|
|
|
980
980
|
expect(resultGuids[i]).toEqual(resultEntities[i].guid);
|
|
981
981
|
}
|
|
982
982
|
resultEntities = await nymph.getEntities({
|
|
983
|
-
class:
|
|
983
|
+
class: TestModel,
|
|
984
984
|
sort: sort,
|
|
985
985
|
reverse: true,
|
|
986
986
|
});
|
|
@@ -988,12 +988,12 @@ This one's zip code is 92064.`;
|
|
|
988
988
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
989
989
|
expect(resultEntities[i + 1][sort]).toBeLessThan(resultEntities[i][sort] ?? 0);
|
|
990
990
|
}
|
|
991
|
-
resultEntities = await nymph.getEntities({ class:
|
|
991
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort: sort }, { type: '&', match: ['name', '^Multi Test '] });
|
|
992
992
|
expect(resultEntities.length).toEqual(100);
|
|
993
993
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
994
994
|
expect(resultEntities[i + 1][sort]).toBeGreaterThan(resultEntities[i][sort] ?? 0);
|
|
995
995
|
}
|
|
996
|
-
resultEntities = await nymph.getEntities({ class:
|
|
996
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort: sort, reverse: true }, { type: '&', match: ['name', '^Multi Test '] });
|
|
997
997
|
expect(resultEntities.length).toEqual(100);
|
|
998
998
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
999
999
|
expect(resultEntities[i + 1][sort]).toBeLessThan(resultEntities[i][sort] ?? 0);
|
|
@@ -1009,14 +1009,12 @@ This one's zip code is 92064.`;
|
|
|
1009
1009
|
await createTestEntities();
|
|
1010
1010
|
expect(await testEntity.$delete()).toEqual(true);
|
|
1011
1011
|
expect(testEntity.guid).toBeNull();
|
|
1012
|
-
const entity = await nymph.getEntity({ class:
|
|
1012
|
+
const entity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid });
|
|
1013
1013
|
expect(entity).toBeNull();
|
|
1014
1014
|
});
|
|
1015
1015
|
}
|
|
1016
1016
|
exports.QueriesTest = QueriesTest;
|
|
1017
1017
|
function UIDTest(nymph, it) {
|
|
1018
|
-
nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
1019
|
-
nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
1020
1018
|
it('delete old test data', async () => {
|
|
1021
1019
|
expect(await nymph.deleteUID('TestUID')).toEqual(true);
|
|
1022
1020
|
expect(await nymph.deleteUID('NewUID')).toEqual(true);
|
|
@@ -1049,22 +1047,22 @@ function UIDTest(nymph, it) {
|
|
|
1049
1047
|
}
|
|
1050
1048
|
exports.UIDTest = UIDTest;
|
|
1051
1049
|
function ExportImportTest(nymph, it) {
|
|
1052
|
-
nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
1053
|
-
nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
1050
|
+
const TestModel = nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
1051
|
+
const TestBModel = nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
1054
1052
|
async function deleteTestData() {
|
|
1055
|
-
let all = await nymph.getEntities({ class:
|
|
1053
|
+
let all = await nymph.getEntities({ class: TestModel });
|
|
1056
1054
|
expect(Array.isArray(all)).toEqual(true);
|
|
1057
1055
|
for (const cur of all) {
|
|
1058
1056
|
expect(await cur.$delete()).toEqual(true);
|
|
1059
1057
|
}
|
|
1060
|
-
all = await nymph.getEntities({ class:
|
|
1058
|
+
all = await nymph.getEntities({ class: TestModel });
|
|
1061
1059
|
expect(all.length).toEqual(0);
|
|
1062
|
-
all = await nymph.getEntities({ class:
|
|
1060
|
+
all = await nymph.getEntities({ class: TestBModel });
|
|
1063
1061
|
expect(Array.isArray(all)).toEqual(true);
|
|
1064
1062
|
for (const cur of all) {
|
|
1065
1063
|
expect(await cur.$delete()).toEqual(true);
|
|
1066
1064
|
}
|
|
1067
|
-
all = await nymph.getEntities({ class:
|
|
1065
|
+
all = await nymph.getEntities({ class: TestBModel });
|
|
1068
1066
|
expect(all.length).toEqual(0);
|
|
1069
1067
|
expect(await nymph.deleteUID('TestUID')).toEqual(true);
|
|
1070
1068
|
expect(await nymph.deleteUID('TestUID2')).toEqual(true);
|
|
@@ -1072,8 +1070,8 @@ function ExportImportTest(nymph, it) {
|
|
|
1072
1070
|
async function checkEntityDataAndCount() {
|
|
1073
1071
|
expect(await nymph.getUID('TestUID')).toEqual(2);
|
|
1074
1072
|
expect(await nymph.getUID('TestUID2')).toEqual(1);
|
|
1075
|
-
const models = await nymph.getEntities({ class:
|
|
1076
|
-
const bmodels = await nymph.getEntities({ class:
|
|
1073
|
+
const models = await nymph.getEntities({ class: TestModel });
|
|
1074
|
+
const bmodels = await nymph.getEntities({ class: TestBModel });
|
|
1077
1075
|
expect(models.length).toEqual(30);
|
|
1078
1076
|
expect(bmodels.length).toEqual(10);
|
|
1079
1077
|
const all = [...models, ...bmodels];
|
|
@@ -1100,7 +1098,7 @@ function ExportImportTest(nymph, it) {
|
|
|
1100
1098
|
expect(await nymph.newUID('TestUID')).toEqual(2);
|
|
1101
1099
|
expect(await nymph.newUID('TestUID2')).toEqual(1);
|
|
1102
1100
|
for (let i = 0; i < 20; i++) {
|
|
1103
|
-
const EntityClass = i < 15 ?
|
|
1101
|
+
const EntityClass = i < 15 ? TestModel : TestBModel;
|
|
1104
1102
|
const testEntity = await EntityClass.factory();
|
|
1105
1103
|
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1106
1104
|
testEntity.null = null;
|
|
@@ -1128,8 +1126,8 @@ function ExportImportTest(nymph, it) {
|
|
|
1128
1126
|
it('import data', async () => {
|
|
1129
1127
|
expect(await nymph.getUID('TestUID')).toBeNull();
|
|
1130
1128
|
expect(await nymph.getUID('TestUID2')).toBeNull();
|
|
1131
|
-
const models = await nymph.getEntities({ class:
|
|
1132
|
-
const bmodels = await nymph.getEntities({ class:
|
|
1129
|
+
const models = await nymph.getEntities({ class: TestModel });
|
|
1130
|
+
const bmodels = await nymph.getEntities({ class: TestBModel });
|
|
1133
1131
|
expect(models.length).toEqual(0);
|
|
1134
1132
|
expect(bmodels.length).toEqual(0);
|
|
1135
1133
|
expect(await nymph.import(__dirname + '/testentityexport.nex')).toEqual(true);
|