@omegup/msync 0.0.76 → 0.0.78
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/index.d.ts +12 -9
- package/index.esm.js +44 -26
- package/index.js +44 -25
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -106,9 +106,10 @@ type Stream<out Q extends O, in out T extends Q, in out F extends HKT<[O, O]>, i
|
|
|
106
106
|
type TS = {
|
|
107
107
|
readonly touchedAt: Timestamp;
|
|
108
108
|
};
|
|
109
|
-
type
|
|
109
|
+
type DDel = {
|
|
110
110
|
readonly deletedAt: Timestamp;
|
|
111
|
-
} & ID & TS
|
|
111
|
+
} & ID & TS;
|
|
112
|
+
type Del = O<DDel>;
|
|
112
113
|
type D = O<{
|
|
113
114
|
readonly deletedAt?: Timestamp | null | undefined;
|
|
114
115
|
} & ID>;
|
|
@@ -479,10 +480,10 @@ declare const $set: <V extends O>() => <R extends O, C = unknown>(fields: MapO<V
|
|
|
479
480
|
declare const $replaceWith: <T extends O, V extends O>(expr: Expr<V, T>) => DeltaStages<O, T, V> & LinStages<O, T, V>;
|
|
480
481
|
|
|
481
482
|
type s$1 = string;
|
|
482
|
-
declare const $unwindDelta: <K1 extends s$1, T extends doc, K2 extends s$1, U extends doc, Null extends null = never>(k1: AsLiteral<K1>, k2: AsLiteral<K2>, k: K1 | K2 | false, includeNull?: Null) => RawStages<Delta<Rec<K1, T>>, Delta<Rec<K1, T> & Rec<K2, Arr<U>>>, Delta<Rec<K1, T> & Rec<K2, U | Null> & ID>>;
|
|
483
|
+
declare const $unwindDelta: <K1 extends s$1, T extends doc, K2 extends s$1, U extends doc, Null extends null = never>(k1: AsLiteral<K1>, k2: AsLiteral<K2>, k: K1 | K2 | false, includeNull?: Null, middle?: string) => RawStages<Delta<Rec<K1, T>>, Delta<Rec<K1, T> & Rec<K2, Arr<U>>>, Delta<Rec<K1, T> & Rec<K2, U | Null> & ID>>;
|
|
483
484
|
|
|
484
485
|
type s = string;
|
|
485
|
-
declare const $unwind: <T extends doc, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, "key"
|
|
486
|
+
declare const $unwind: <T extends doc, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, "key">, middle?: string) => DeltaStages<O, T & Rec<K, Arr<U>>, T & Rec<K, U>>;
|
|
486
487
|
|
|
487
488
|
type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
|
|
488
489
|
type Patch<V, KK extends StrKey<V> = StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
|
|
@@ -493,10 +494,12 @@ declare const $merge: <V extends O>() => <Out extends doc, SourcePart extends do
|
|
|
493
494
|
type ND = {
|
|
494
495
|
readonly deletedAt?: null;
|
|
495
496
|
};
|
|
496
|
-
type
|
|
497
|
-
|
|
498
|
-
declare const $
|
|
499
|
-
declare const $
|
|
497
|
+
type SafeE<E> = Omit<E, `$${string}` | keyof ID>;
|
|
498
|
+
type Merge<T extends doc, E> = Omit<SafeE<E>, keyof (ND & TS)> & ((T & ND & TS) | Del);
|
|
499
|
+
declare const $insertX: <T extends doc, D extends O, EEE>(out: RWCollection<Merge<T, EEE>>, expr: Expr<T, D>, map: (x: Expr<T & ND & TS & Omit<SafeE<EEE>, keyof (ND & TS)>, D>) => Expr<Merge<T, EEE>, D>, ext: ExprsExact<Omit<SafeE<EEE>, keyof (ND & TS)>, unknown>) => StreamRunnerParam<D, "out">;
|
|
500
|
+
declare const $simpleInsert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<T, "out">;
|
|
501
|
+
declare const $insertPart: <T extends doc, EEE>(out: RWCollection<Merge<T, EEE>>, ext: ExprsExact<Omit<SafeE<EEE>, keyof (ND & TS)>, unknown>) => StreamRunnerParam<Delta<T>, "out">;
|
|
502
|
+
declare const $insert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
500
503
|
|
|
501
504
|
declare const $group_: <V extends O>() => <ID, T extends O, C = unknown>(id: Expr<ID, T, C>, args: Accumulators<T, V, C>) => RawStages<O, T, Rec<"_id", ID> & V, C, 1>;
|
|
502
505
|
|
|
@@ -692,4 +695,4 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
|
|
|
692
695
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
693
696
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
694
697
|
|
|
695
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $unwind, $unwindDelta, type Accumulators, type Arr, type AsLiteral, type Delta, type DeltaAccumulator, type DeltaAccumulators, Expr, type ExprHKT, type Exprs, type ExprsExact, type ExprsExactHKT, type ExprsPart, Field, type ID, type Loose, Machine, type Merge, type MergeArgs, type MergeInto, type MergeMapOArgs, type Model, type MongoTypeNames, type N, type NoRaw, type NullToOBJ, type O, type OPick, type OPickD, type RONoRaw, type RORec, type RawStages, type Rec, type Replace, type SnapshotStreamExecutionResult, type StrKey, type Strict, type TS, Type, type WriteonlyCollection, add, and, anyElementTrue, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, type doc, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, not, type notArr, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
698
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $unwind, $unwindDelta, type Accumulators, type Arr, type AsLiteral, type Delta, type DeltaAccumulator, type DeltaAccumulators, Expr, type ExprHKT, type Exprs, type ExprsExact, type ExprsExactHKT, type ExprsPart, Field, type ID, type Loose, Machine, type Merge, type MergeArgs, type MergeInto, type MergeMapOArgs, type Model, type MongoTypeNames, type N, type NoRaw, type NullToOBJ, type O, type OPick, type OPickD, type RONoRaw, type RORec, type RawStages, type Rec, type Replace, type SnapshotStreamExecutionResult, type StrKey, type Strict, type TS, Type, type WriteonlyCollection, add, and, anyElementTrue, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, type doc, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, not, type notArr, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.esm.js
CHANGED
|
@@ -339,6 +339,7 @@ const assertEqual = () => ({
|
|
|
339
339
|
});
|
|
340
340
|
const omitRORec = () => assertEqual();
|
|
341
341
|
const omitPick = () => assertEqual();
|
|
342
|
+
const translateOmit = () => assertEqual();
|
|
342
343
|
|
|
343
344
|
const asStages = (x) => x;
|
|
344
345
|
const concatStages = (part1, part2) => asStages([...part1, ...part2]);
|
|
@@ -931,7 +932,7 @@ const dualIn = operator();
|
|
|
931
932
|
const $in = dualIn('$in');
|
|
932
933
|
const $nin = dualIn('$nin');
|
|
933
934
|
|
|
934
|
-
const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
935
|
+
const $unwindDelta = (k1, k2, k, includeNull, middle) => {
|
|
935
936
|
const outer = includeNull === null;
|
|
936
937
|
const newItems = {
|
|
937
938
|
$filter: {
|
|
@@ -977,7 +978,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
|
977
978
|
},
|
|
978
979
|
};
|
|
979
980
|
const ifNull = (k, part, str = `$${k}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
|
|
980
|
-
const interDot = ([a, b]) => [a, '.', b];
|
|
981
|
+
const interDot = ([a, b]) => [a, middle ?? '.', b];
|
|
981
982
|
const partReplace = (part) => ({
|
|
982
983
|
$cond: {
|
|
983
984
|
if: { $or: [{ $eq: [`$${k1}.${part}`, null] }, { $eq: [`$${k2}.${part}`, null] }] },
|
|
@@ -1058,18 +1059,25 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
|
1058
1059
|
after: partReplace('after'),
|
|
1059
1060
|
},
|
|
1060
1061
|
},
|
|
1062
|
+
...(!k && middle
|
|
1063
|
+
? [
|
|
1064
|
+
{
|
|
1065
|
+
$set: { _id: { $ifNull: ['$before._id', '$after._id'] } },
|
|
1066
|
+
},
|
|
1067
|
+
]
|
|
1068
|
+
: []),
|
|
1061
1069
|
]))
|
|
1062
1070
|
.with($match_($expr(ne(part('before'))(part('after'))))).stages;
|
|
1063
1071
|
return stages;
|
|
1064
1072
|
};
|
|
1065
1073
|
|
|
1066
|
-
const $unwind = (k, dict) => ({
|
|
1074
|
+
const $unwind = (k, dict, middle) => ({
|
|
1067
1075
|
delta: link()
|
|
1068
1076
|
.with($replaceWithDelta(field({
|
|
1069
1077
|
left: ['left', root().expr()],
|
|
1070
1078
|
right: ['right', root().of(k).expr()],
|
|
1071
1079
|
})))
|
|
1072
|
-
.with($unwindDelta('left', 'right', false))
|
|
1080
|
+
.with($unwindDelta('left', 'right', false, undefined, middle))
|
|
1073
1081
|
.with($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({
|
|
1074
1082
|
key: root().of('right').expr(),
|
|
1075
1083
|
}, dict)))).stages,
|
|
@@ -1378,30 +1386,40 @@ const $simpleMerge = () => (out, keys) => $mergeX(out, keys, root(), id$1);
|
|
|
1378
1386
|
const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()));
|
|
1379
1387
|
const assertNotNull$1 = (expr) => expr;
|
|
1380
1388
|
|
|
1381
|
-
const $insertX = (out, expr, map) =>
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1389
|
+
const $insertX = (out, expr, map, ext) => {
|
|
1390
|
+
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
1391
|
+
return {
|
|
1392
|
+
teardown: c => c({
|
|
1393
|
+
collection: out,
|
|
1394
|
+
method: 'updateMany',
|
|
1395
|
+
params: [
|
|
1396
|
+
filter,
|
|
1397
|
+
[{ $set: { deletedAt: '$$NOW', touchedAt: '$$CLUSTER_TIME' } }],
|
|
1398
|
+
],
|
|
1399
|
+
}),
|
|
1400
|
+
raw: () => {
|
|
1401
|
+
const replacer = map(mergeObjects(expr, field(mergeExpr(ext, {
|
|
1402
|
+
deletedAt: ['deletedAt', nil],
|
|
1403
|
+
touchedAt: ['touchedAt', current],
|
|
1404
|
+
}))));
|
|
1405
|
+
return link()
|
|
1406
|
+
.with($replaceWith_(replacer))
|
|
1407
|
+
.with($merge_({
|
|
1408
|
+
into: out,
|
|
1409
|
+
on: root().of('_id'),
|
|
1410
|
+
whenMatched: 'merge',
|
|
1411
|
+
whenNotMatched: 'insert',
|
|
1412
|
+
})).stages;
|
|
1413
|
+
},
|
|
1414
|
+
};
|
|
1415
|
+
};
|
|
1416
|
+
const $simpleInsert = (out) => $insertX(out, root().expr(), id$1, {});
|
|
1417
|
+
const $insertPart = (out, ext) => $insertX(out, assertNotNull(root().of('after').expr()), x => ite(eq(root().of('after').expr())(nil), field(mergeExpr(translateOmit().forward(ext), {
|
|
1401
1418
|
deletedAt: ['deletedAt', current],
|
|
1402
1419
|
_id: ['_id', assertNotNull(root().of('before').of('_id').expr())],
|
|
1403
1420
|
touchedAt: ['touchedAt', current],
|
|
1404
|
-
}), x));
|
|
1421
|
+
})), x), ext);
|
|
1422
|
+
const $insert = (out) => $insertPart(out, {});
|
|
1405
1423
|
const assertNotNull = (expr) => expr;
|
|
1406
1424
|
|
|
1407
1425
|
const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
|
|
@@ -1899,4 +1917,4 @@ const makeCol = async (docs, database, name) => {
|
|
|
1899
1917
|
}
|
|
1900
1918
|
};
|
|
1901
1919
|
|
|
1902
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, array, ceil, comp, concat$1 as concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first$1 as first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, not, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
1920
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, array, ceil, comp, concat$1 as concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first$1 as first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, not, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.js
CHANGED
|
@@ -341,6 +341,7 @@ const assertEqual = () => ({
|
|
|
341
341
|
});
|
|
342
342
|
const omitRORec = () => assertEqual();
|
|
343
343
|
const omitPick = () => assertEqual();
|
|
344
|
+
const translateOmit = () => assertEqual();
|
|
344
345
|
|
|
345
346
|
const asStages = (x) => x;
|
|
346
347
|
const concatStages = (part1, part2) => asStages([...part1, ...part2]);
|
|
@@ -933,7 +934,7 @@ const dualIn = operator();
|
|
|
933
934
|
const $in = dualIn('$in');
|
|
934
935
|
const $nin = dualIn('$nin');
|
|
935
936
|
|
|
936
|
-
const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
937
|
+
const $unwindDelta = (k1, k2, k, includeNull, middle) => {
|
|
937
938
|
const outer = includeNull === null;
|
|
938
939
|
const newItems = {
|
|
939
940
|
$filter: {
|
|
@@ -979,7 +980,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
|
979
980
|
},
|
|
980
981
|
};
|
|
981
982
|
const ifNull = (k, part, str = `$${k}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
|
|
982
|
-
const interDot = ([a, b]) => [a, '.', b];
|
|
983
|
+
const interDot = ([a, b]) => [a, middle ?? '.', b];
|
|
983
984
|
const partReplace = (part) => ({
|
|
984
985
|
$cond: {
|
|
985
986
|
if: { $or: [{ $eq: [`$${k1}.${part}`, null] }, { $eq: [`$${k2}.${part}`, null] }] },
|
|
@@ -1060,18 +1061,25 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
|
1060
1061
|
after: partReplace('after'),
|
|
1061
1062
|
},
|
|
1062
1063
|
},
|
|
1064
|
+
...(!k && middle
|
|
1065
|
+
? [
|
|
1066
|
+
{
|
|
1067
|
+
$set: { _id: { $ifNull: ['$before._id', '$after._id'] } },
|
|
1068
|
+
},
|
|
1069
|
+
]
|
|
1070
|
+
: []),
|
|
1063
1071
|
]))
|
|
1064
1072
|
.with($match_($expr(ne(part('before'))(part('after'))))).stages;
|
|
1065
1073
|
return stages;
|
|
1066
1074
|
};
|
|
1067
1075
|
|
|
1068
|
-
const $unwind = (k, dict) => ({
|
|
1076
|
+
const $unwind = (k, dict, middle) => ({
|
|
1069
1077
|
delta: link()
|
|
1070
1078
|
.with($replaceWithDelta(field({
|
|
1071
1079
|
left: ['left', root().expr()],
|
|
1072
1080
|
right: ['right', root().of(k).expr()],
|
|
1073
1081
|
})))
|
|
1074
|
-
.with($unwindDelta('left', 'right', false))
|
|
1082
|
+
.with($unwindDelta('left', 'right', false, undefined, middle))
|
|
1075
1083
|
.with($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({
|
|
1076
1084
|
key: root().of('right').expr(),
|
|
1077
1085
|
}, dict)))).stages,
|
|
@@ -1380,30 +1388,40 @@ const $simpleMerge = () => (out, keys) => $mergeX(out, keys, root(), id$1);
|
|
|
1380
1388
|
const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()));
|
|
1381
1389
|
const assertNotNull$1 = (expr) => expr;
|
|
1382
1390
|
|
|
1383
|
-
const $insertX = (out, expr, map) =>
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1391
|
+
const $insertX = (out, expr, map, ext) => {
|
|
1392
|
+
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
1393
|
+
return {
|
|
1394
|
+
teardown: c => c({
|
|
1395
|
+
collection: out,
|
|
1396
|
+
method: 'updateMany',
|
|
1397
|
+
params: [
|
|
1398
|
+
filter,
|
|
1399
|
+
[{ $set: { deletedAt: '$$NOW', touchedAt: '$$CLUSTER_TIME' } }],
|
|
1400
|
+
],
|
|
1401
|
+
}),
|
|
1402
|
+
raw: () => {
|
|
1403
|
+
const replacer = map(mergeObjects(expr, field(mergeExpr(ext, {
|
|
1404
|
+
deletedAt: ['deletedAt', nil],
|
|
1405
|
+
touchedAt: ['touchedAt', current],
|
|
1406
|
+
}))));
|
|
1407
|
+
return link()
|
|
1408
|
+
.with($replaceWith_(replacer))
|
|
1409
|
+
.with($merge_({
|
|
1410
|
+
into: out,
|
|
1411
|
+
on: root().of('_id'),
|
|
1412
|
+
whenMatched: 'merge',
|
|
1413
|
+
whenNotMatched: 'insert',
|
|
1414
|
+
})).stages;
|
|
1415
|
+
},
|
|
1416
|
+
};
|
|
1417
|
+
};
|
|
1418
|
+
const $simpleInsert = (out) => $insertX(out, root().expr(), id$1, {});
|
|
1419
|
+
const $insertPart = (out, ext) => $insertX(out, assertNotNull(root().of('after').expr()), x => ite(eq(root().of('after').expr())(nil), field(mergeExpr(translateOmit().forward(ext), {
|
|
1403
1420
|
deletedAt: ['deletedAt', current],
|
|
1404
1421
|
_id: ['_id', assertNotNull(root().of('before').of('_id').expr())],
|
|
1405
1422
|
touchedAt: ['touchedAt', current],
|
|
1406
|
-
}), x));
|
|
1423
|
+
})), x), ext);
|
|
1424
|
+
const $insert = (out) => $insertPart(out, {});
|
|
1407
1425
|
const assertNotNull = (expr) => expr;
|
|
1408
1426
|
|
|
1409
1427
|
const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
|
|
@@ -1920,6 +1938,7 @@ exports.$gteTs = $gteTs;
|
|
|
1920
1938
|
exports.$ifNull = $ifNull;
|
|
1921
1939
|
exports.$in = $in;
|
|
1922
1940
|
exports.$insert = $insert;
|
|
1941
|
+
exports.$insertPart = $insertPart;
|
|
1923
1942
|
exports.$insertX = $insertX;
|
|
1924
1943
|
exports.$keys = $keys;
|
|
1925
1944
|
exports.$let = $let;
|