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