corebasic 1.0.231 → 1.0.233
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/dist/libs/auth.js +3 -3
- package/dist/libs/dip/suffix/index.js +1 -1
- package/dist/libs/dip/suffix/suffix.js +2 -3
- package/dist/libs/dip/suffix/tests/policy.applySuffixPolicy.test.js +26 -99
- package/dist/libs/dip/suffix/tests/policy.test.js +1 -1
- package/dist/libs/dip.js +1 -0
- package/dist/libs/dipper.js +13 -12
- package/dist/libs/elabase.js +36 -45
- package/dist/libs/features.js +113 -62
- package/dist/libs/kafka.js +5 -8
- package/dist/libs/messaging.js +1 -1
- package/dist/libs/utils.js +1 -1
- package/libs/auth.ts +3 -3
- package/libs/dip/suffix/index.ts +1 -1
- package/libs/dip/suffix/policy.ts +1 -1
- package/libs/dip/suffix/suffix.ts +3 -4
- package/libs/dip/suffix/tests/policy.applySuffixPolicy.test.ts +26 -180
- package/libs/dip/suffix/tests/policy.test.ts +1 -1
- package/libs/dip.ts +7 -5
- package/libs/dipper.ts +14 -13
- package/libs/elabase.ts +172 -126
- package/libs/features.ts +234 -96
- package/libs/kafka.ts +12 -14
- package/libs/messaging.ts +2 -2
- package/libs/utils.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.json +16 -1
|
@@ -2,6 +2,8 @@ import { describe, test } from "node:test";
|
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import {applySuffixPolicy} from "../policy.ts";
|
|
4
4
|
|
|
5
|
+
let insertMode = false
|
|
6
|
+
const arg = {db: "test-db", collection: ["test-collection"]}
|
|
5
7
|
// -----------------------------------------------------------------------------
|
|
6
8
|
// applySuffixPolicy()
|
|
7
9
|
// -----------------------------------------------------------------------------
|
|
@@ -10,7 +12,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
10
12
|
test("no collection", async () => {
|
|
11
13
|
const collections = {};
|
|
12
14
|
|
|
13
|
-
const result = await applySuffixPolicy(collections, "missing", {});
|
|
15
|
+
const result = await applySuffixPolicy(collections, "missing", {}, insertMode, arg);
|
|
14
16
|
|
|
15
17
|
assert.deepEqual(result, []);
|
|
16
18
|
});
|
|
@@ -20,7 +22,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
20
22
|
invoices: {}
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
const result = await applySuffixPolicy(collections, "invoices", {});
|
|
25
|
+
const result = await applySuffixPolicy(collections, "invoices", {}, insertMode, arg);
|
|
24
26
|
|
|
25
27
|
assert.deepEqual(result, []);
|
|
26
28
|
});
|
|
@@ -32,7 +34,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
32
34
|
}
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
const result = await applySuffixPolicy(collections, "invoices", {});
|
|
37
|
+
const result = await applySuffixPolicy(collections, "invoices", {}, insertMode, arg);
|
|
36
38
|
|
|
37
39
|
assert.deepEqual(result, []);
|
|
38
40
|
});
|
|
@@ -48,13 +50,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
48
50
|
}
|
|
49
51
|
};
|
|
50
52
|
|
|
51
|
-
const result = await applySuffixPolicy(
|
|
52
|
-
collections as any,
|
|
53
|
-
"invoices",
|
|
54
|
-
{
|
|
55
|
-
type: "Sales"
|
|
56
|
-
}
|
|
57
|
-
);
|
|
53
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {type: "Sales"}, insertMode, arg);
|
|
58
54
|
|
|
59
55
|
assert.deepEqual(result, [
|
|
60
56
|
"/Sales"
|
|
@@ -74,17 +70,8 @@ describe("applySuffixPolicy()", () => {
|
|
|
74
70
|
}
|
|
75
71
|
};
|
|
76
72
|
|
|
77
|
-
const result = await applySuffixPolicy(
|
|
78
|
-
|
|
79
|
-
"invoices",
|
|
80
|
-
{
|
|
81
|
-
type: "Sales"
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
assert.deepEqual(result, [
|
|
86
|
-
"/Sales"
|
|
87
|
-
]);
|
|
73
|
+
const result = await applySuffixPolicy(collections as any, "invoices", { type: "Sales" }, insertMode, arg);
|
|
74
|
+
assert.deepEqual(result, ["/Sales"]);
|
|
88
75
|
});
|
|
89
76
|
|
|
90
77
|
test("unconditional policy", async () => {
|
|
@@ -99,13 +86,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
99
86
|
}
|
|
100
87
|
};
|
|
101
88
|
|
|
102
|
-
const result = await applySuffixPolicy(
|
|
103
|
-
collections as any,
|
|
104
|
-
"invoices",
|
|
105
|
-
{
|
|
106
|
-
type: "Sales"
|
|
107
|
-
}
|
|
108
|
-
);
|
|
89
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {type: "Sales"}, insertMode, arg);
|
|
109
90
|
|
|
110
91
|
assert.deepEqual(result, [
|
|
111
92
|
"/Sales"
|
|
@@ -126,14 +107,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
126
107
|
}
|
|
127
108
|
};
|
|
128
109
|
|
|
129
|
-
const result = await applySuffixPolicy(
|
|
130
|
-
collections as any,
|
|
131
|
-
"invoices",
|
|
132
|
-
{
|
|
133
|
-
status: "Active",
|
|
134
|
-
type: "Sales"
|
|
135
|
-
}
|
|
136
|
-
);
|
|
110
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {status: "Active", type: "Sales"}, insertMode, arg);
|
|
137
111
|
|
|
138
112
|
assert.deepEqual(result, [
|
|
139
113
|
"/Sales"
|
|
@@ -154,14 +128,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
154
128
|
}
|
|
155
129
|
};
|
|
156
130
|
|
|
157
|
-
const result = await applySuffixPolicy(
|
|
158
|
-
collections as any,
|
|
159
|
-
"invoices",
|
|
160
|
-
{
|
|
161
|
-
status: "Deleted",
|
|
162
|
-
type: "Sales"
|
|
163
|
-
}
|
|
164
|
-
);
|
|
131
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {status: "Deleted", type: "Sales"}, insertMode, arg);
|
|
165
132
|
|
|
166
133
|
assert.deepEqual(result, []);
|
|
167
134
|
});
|
|
@@ -180,14 +147,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
180
147
|
}
|
|
181
148
|
};
|
|
182
149
|
|
|
183
|
-
const result = await applySuffixPolicy(
|
|
184
|
-
collections as any,
|
|
185
|
-
"invoices",
|
|
186
|
-
{
|
|
187
|
-
status: {$in: ["Active", "Pending"]},
|
|
188
|
-
type: "Sales"
|
|
189
|
-
}
|
|
190
|
-
);
|
|
150
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {status: {$in: ["Active", "Pending"]}, type: "Sales"}, insertMode, arg);
|
|
191
151
|
|
|
192
152
|
assert.deepEqual(result, [
|
|
193
153
|
"/Sales"
|
|
@@ -218,15 +178,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
218
178
|
}
|
|
219
179
|
};
|
|
220
180
|
|
|
221
|
-
const result = await applySuffixPolicy(
|
|
222
|
-
collections as any,
|
|
223
|
-
"invoices",
|
|
224
|
-
{
|
|
225
|
-
status: "Active",
|
|
226
|
-
type: "Sales",
|
|
227
|
-
region: "IN"
|
|
228
|
-
}
|
|
229
|
-
);
|
|
181
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {status: "Active", type: "Sales", region: "IN"}, insertMode, arg);
|
|
230
182
|
|
|
231
183
|
assert.deepEqual(
|
|
232
184
|
result.sort(),
|
|
@@ -261,15 +213,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
261
213
|
}
|
|
262
214
|
};
|
|
263
215
|
|
|
264
|
-
const result = await applySuffixPolicy(
|
|
265
|
-
collections as any,
|
|
266
|
-
"invoices",
|
|
267
|
-
{
|
|
268
|
-
status: "Active",
|
|
269
|
-
type: "Sales",
|
|
270
|
-
region: "IN"
|
|
271
|
-
}
|
|
272
|
-
);
|
|
216
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {status: "Active", type: "Sales", region: "IN"}, insertMode, arg);
|
|
273
217
|
|
|
274
218
|
assert.deepEqual(result, [
|
|
275
219
|
"/Sales"
|
|
@@ -294,13 +238,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
294
238
|
}
|
|
295
239
|
};
|
|
296
240
|
|
|
297
|
-
const result = await applySuffixPolicy(
|
|
298
|
-
collections as any,
|
|
299
|
-
"invoices",
|
|
300
|
-
{
|
|
301
|
-
type: "Sales"
|
|
302
|
-
}
|
|
303
|
-
);
|
|
241
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {type: "Sales"}, insertMode, arg);
|
|
304
242
|
|
|
305
243
|
assert.deepEqual(result, [
|
|
306
244
|
"/Sales"
|
|
@@ -321,13 +259,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
321
259
|
}
|
|
322
260
|
};
|
|
323
261
|
|
|
324
|
-
const result = await applySuffixPolicy(
|
|
325
|
-
collections as any,
|
|
326
|
-
"invoices",
|
|
327
|
-
{
|
|
328
|
-
date: new Date(2026, 4, 3).getTime()
|
|
329
|
-
}
|
|
330
|
-
);
|
|
262
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {date: new Date(2026, 4, 3).getTime()}, insertMode, arg);
|
|
331
263
|
|
|
332
264
|
assert.deepEqual(result, [
|
|
333
265
|
"/2026"
|
|
@@ -349,14 +281,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
349
281
|
}
|
|
350
282
|
};
|
|
351
283
|
|
|
352
|
-
const result = await applySuffixPolicy(
|
|
353
|
-
collections as any,
|
|
354
|
-
"invoices",
|
|
355
|
-
{
|
|
356
|
-
type: "Sales",
|
|
357
|
-
date: new Date(2026, 4, 3).getTime()
|
|
358
|
-
}
|
|
359
|
-
);
|
|
284
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {type: "Sales", date: new Date(2026, 4, 3).getTime()}, insertMode, arg);
|
|
360
285
|
|
|
361
286
|
assert.deepEqual(result, [
|
|
362
287
|
"/Sales/2026"
|
|
@@ -379,16 +304,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
379
304
|
}
|
|
380
305
|
};
|
|
381
306
|
|
|
382
|
-
const result = await applySuffixPolicy(
|
|
383
|
-
collections as any,
|
|
384
|
-
"invoices",
|
|
385
|
-
{
|
|
386
|
-
age: {
|
|
387
|
-
$gt: 20
|
|
388
|
-
},
|
|
389
|
-
type: "Sales"
|
|
390
|
-
}
|
|
391
|
-
);
|
|
307
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {age: {$gt: 20}, type: "Sales"}, insertMode, arg);
|
|
392
308
|
|
|
393
309
|
assert.deepEqual(result, [
|
|
394
310
|
"/Sales"
|
|
@@ -411,16 +327,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
411
327
|
}
|
|
412
328
|
};
|
|
413
329
|
|
|
414
|
-
const result = await applySuffixPolicy(
|
|
415
|
-
collections as any,
|
|
416
|
-
"invoices",
|
|
417
|
-
{
|
|
418
|
-
age: {
|
|
419
|
-
$lt: 10
|
|
420
|
-
},
|
|
421
|
-
type: "Sales"
|
|
422
|
-
}
|
|
423
|
-
);
|
|
330
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {age: {$lt: 10}, type: "Sales"}, insertMode, arg);
|
|
424
331
|
|
|
425
332
|
assert.deepEqual(result, []);
|
|
426
333
|
});
|
|
@@ -442,14 +349,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
442
349
|
};
|
|
443
350
|
|
|
444
351
|
await assert.rejects(async () => {
|
|
445
|
-
await applySuffixPolicy(
|
|
446
|
-
collections as any,
|
|
447
|
-
"invoices",
|
|
448
|
-
{
|
|
449
|
-
status: "Active",
|
|
450
|
-
type: "Sales"
|
|
451
|
-
}
|
|
452
|
-
);
|
|
352
|
+
await applySuffixPolicy(collections as any, "invoices", {status: "Active", type: "Sales"}, insertMode, arg);
|
|
453
353
|
});
|
|
454
354
|
});
|
|
455
355
|
|
|
@@ -467,17 +367,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
467
367
|
}
|
|
468
368
|
};
|
|
469
369
|
|
|
470
|
-
const result = await applySuffixPolicy(
|
|
471
|
-
collections as any,
|
|
472
|
-
"invoices",
|
|
473
|
-
{
|
|
474
|
-
age: {
|
|
475
|
-
$gt: 5,
|
|
476
|
-
$lt: 15
|
|
477
|
-
},
|
|
478
|
-
type: "Sales"
|
|
479
|
-
}
|
|
480
|
-
);
|
|
370
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {age: {$gt: 5, $lt: 15}, type: "Sales"}, insertMode, arg);
|
|
481
371
|
|
|
482
372
|
assert.deepEqual(result, [
|
|
483
373
|
"/Sales"
|
|
@@ -498,17 +388,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
498
388
|
}
|
|
499
389
|
};
|
|
500
390
|
|
|
501
|
-
const result = await applySuffixPolicy(
|
|
502
|
-
collections as any,
|
|
503
|
-
"invoices",
|
|
504
|
-
{
|
|
505
|
-
age: {
|
|
506
|
-
$gt: 5,
|
|
507
|
-
$lt: 15
|
|
508
|
-
},
|
|
509
|
-
type: "Sales"
|
|
510
|
-
}
|
|
511
|
-
);
|
|
391
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {age: {$gt: 5,$lt: 15}, type: "Sales"}, insertMode, arg);
|
|
512
392
|
|
|
513
393
|
assert.deepEqual(result, []);
|
|
514
394
|
});
|
|
@@ -530,14 +410,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
530
410
|
}
|
|
531
411
|
};
|
|
532
412
|
|
|
533
|
-
const result = await applySuffixPolicy(
|
|
534
|
-
collections as any,
|
|
535
|
-
"invoices",
|
|
536
|
-
{
|
|
537
|
-
age: { $in: [10] },
|
|
538
|
-
type: "Sales"
|
|
539
|
-
}
|
|
540
|
-
);
|
|
413
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {age: { $in: [10] }, type: "Sales"}, insertMode, arg);
|
|
541
414
|
|
|
542
415
|
assert.deepEqual(result, [
|
|
543
416
|
"/Sales"
|
|
@@ -561,14 +434,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
561
434
|
}
|
|
562
435
|
};
|
|
563
436
|
|
|
564
|
-
const result = await applySuffixPolicy(
|
|
565
|
-
collections as any,
|
|
566
|
-
"invoices",
|
|
567
|
-
{
|
|
568
|
-
age: { $in: [10] },
|
|
569
|
-
type: "Sales"
|
|
570
|
-
}
|
|
571
|
-
);
|
|
437
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {age: { $in: [10] }, type: "Sales"}, insertMode, arg);
|
|
572
438
|
|
|
573
439
|
assert.deepEqual(result, []);
|
|
574
440
|
});
|
|
@@ -590,17 +456,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
590
456
|
}
|
|
591
457
|
};
|
|
592
458
|
|
|
593
|
-
const result = await applySuffixPolicy(
|
|
594
|
-
collections as any,
|
|
595
|
-
"invoices",
|
|
596
|
-
{
|
|
597
|
-
age: {
|
|
598
|
-
$gt: 20,
|
|
599
|
-
$lt: 40
|
|
600
|
-
},
|
|
601
|
-
type: "Sales"
|
|
602
|
-
}
|
|
603
|
-
);
|
|
459
|
+
const result = await applySuffixPolicy(collections as any, "invoices",{age: {$gt: 20, $lt: 40}, type: "Sales"}, insertMode, arg);
|
|
604
460
|
|
|
605
461
|
assert.deepEqual(result, [
|
|
606
462
|
"/Sales"
|
|
@@ -624,17 +480,7 @@ describe("applySuffixPolicy()", () => {
|
|
|
624
480
|
}
|
|
625
481
|
};
|
|
626
482
|
|
|
627
|
-
const result = await applySuffixPolicy(
|
|
628
|
-
collections as any,
|
|
629
|
-
"invoices",
|
|
630
|
-
{
|
|
631
|
-
age: {
|
|
632
|
-
$gt: 10,
|
|
633
|
-
$lt: 20
|
|
634
|
-
},
|
|
635
|
-
type: "Sales"
|
|
636
|
-
}
|
|
637
|
-
);
|
|
483
|
+
const result = await applySuffixPolicy(collections as any, "invoices", {age: {$gt: 10, $lt: 20}, type: "Sales"}, insertMode, arg);
|
|
638
484
|
|
|
639
485
|
assert.deepEqual(result, []);
|
|
640
486
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, test } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
|
-
import {matchPolicy, overlaps, contains, intersects
|
|
3
|
+
import {matchPolicy, overlaps, contains, intersects} from "../policy.ts";
|
|
4
4
|
|
|
5
5
|
const defaultBounds = {values: [], from: -Infinity, to: Infinity, fromOp: "$gte", toOp: "$lte"}
|
|
6
6
|
|
package/libs/dip.ts
CHANGED
|
@@ -18,6 +18,8 @@ export const companyMeta = Elabase.companyMeta
|
|
|
18
18
|
export const outletMeta = Elabase.outletMeta
|
|
19
19
|
export const customMeta = Elabase.customMeta
|
|
20
20
|
export const schema = Elabase.schema
|
|
21
|
+
export type DipMeta = Elabase.DipMeta;
|
|
22
|
+
export const DipMeta = Elabase.DipMeta;
|
|
21
23
|
export const isDipMeta = Elabase.isDipMeta
|
|
22
24
|
export const excludeCollectionConfig = Elabase.excludeCollectionConfig
|
|
23
25
|
export const includeCollectionConfig = Elabase.includeCollectionConfig
|
|
@@ -62,14 +64,14 @@ export const IdempotentDip = (): IdempotentDip => {
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
idip.insert = async function (collection, query, data) {
|
|
65
|
-
await Elabase.update(state.meta
|
|
67
|
+
await Elabase.update(state.meta!, collection, query, { $setOnInsert: data }, {upsert: true})
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
idip.update = async function (collection, query, data, rollback) {
|
|
69
71
|
let token = { [state.txn]: true }
|
|
70
72
|
let idempotent = { [state.txn]: { $exists: rollback ?? false } }
|
|
71
|
-
let result = await Elabase.update(state.meta
|
|
72
|
-
return result.count ? true : (await Elabase.query(state.meta
|
|
73
|
+
let result = await Elabase.update(state.meta!, collection, {...query, ...idempotent}, {...data, $setOnInsert: undefined, $set: {...(data.$set ?? {}), ...token} })
|
|
74
|
+
return result.count ? true : (await Elabase.query(state.meta!, collection, {...query, ...idempotent})).length
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
idip.upsert = async function (collection, query, data, rollback) {
|
|
@@ -78,11 +80,11 @@ export const IdempotentDip = (): IdempotentDip => {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
idip.cleanup = async function (collection, query) {
|
|
81
|
-
await Elabase.update(state.meta
|
|
83
|
+
await Elabase.update(state.meta!, collection, query, { $unset: { [state.txn]: true } })
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
idip.finish = async function () {
|
|
85
|
-
return await Elabase.update(state.meta
|
|
87
|
+
return await Elabase.update(state.meta!, "txns",{_id: state.txn}, {}, {upsert: true})
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
return idip
|
package/libs/dipper.ts
CHANGED
|
@@ -6,7 +6,6 @@ import axios from 'axios'
|
|
|
6
6
|
type DipperIdQuery = string | string[] | { $in: string[] }
|
|
7
7
|
|
|
8
8
|
type DipperArg = {
|
|
9
|
-
mode: string
|
|
10
9
|
query?: {
|
|
11
10
|
_id?: DipperIdQuery
|
|
12
11
|
}
|
|
@@ -25,16 +24,16 @@ function hashStr(str: string) {
|
|
|
25
24
|
return hash;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
function hash(string: string, digits: number) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
27
|
+
// function hash(string: string, digits: number) {
|
|
28
|
+
// digits = digits || 6;
|
|
29
|
+
// var m = Math.pow(10, digits+1) - 1;
|
|
30
|
+
// var phi = Math.pow(10, digits) / 2 - 1;
|
|
31
|
+
// var n = 0;
|
|
32
|
+
// for (var i = 0; i < string.length; i++) {
|
|
33
|
+
// n = (n + phi * string.charCodeAt(i)) % m;
|
|
34
|
+
// }
|
|
35
|
+
// return n.toString();
|
|
36
|
+
// }
|
|
38
37
|
let shards: string[] = []
|
|
39
38
|
let shardCount = 20
|
|
40
39
|
|
|
@@ -67,6 +66,8 @@ async function postDip(url: string | URL, arg: unknown) {
|
|
|
67
66
|
|
|
68
67
|
export default async function dipper(arg: DipperArg) {
|
|
69
68
|
|
|
69
|
+
const mode: string = arg.insert || arg.update || arg.delete ? "query" : "command" // TODO: batch
|
|
70
|
+
|
|
70
71
|
let result = []
|
|
71
72
|
|
|
72
73
|
let _id = arg.query?._id ?? arg.insert?._id ?? undefined
|
|
@@ -90,12 +91,12 @@ export default async function dipper(arg: DipperArg) {
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
if (
|
|
94
|
+
if (mode === "query")
|
|
94
95
|
result = result.reduce( (partial, item) => partial.concat(item), [])
|
|
95
96
|
|
|
96
97
|
|
|
97
98
|
|
|
98
|
-
return
|
|
99
|
+
return mode === "query" ? result : result[0]
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
|