@omegup/msync 0.1.8 → 0.1.10
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 +39 -27
- package/index.esm.js +213 -226
- package/index.js +213 -225
- package/package.json +1 -1
- package/lib/accumulators/index.d.ts +0 -10
- package/lib/aggregate/$merge.d.ts +0 -19
- package/lib/aggregate/$upsert.d.ts +0 -15
- package/lib/aggregate/group/$group-merge.d.ts +0 -12
- package/lib/aggregate/group/index.d.ts +0 -2
- package/lib/aggregate/group/utils/sub-group.d.ts +0 -6
- package/lib/aggregate/group/utils/sub-merge.d.ts +0 -18
- package/lib/aggregate/index.d.ts +0 -9
- package/lib/aggregate/lookup/$lookup-delta.d.ts +0 -10
- package/lib/aggregate/lookup/$lookup-raw.d.ts +0 -9
- package/lib/aggregate/lookup/index.d.ts +0 -12
- package/lib/aggregate/match/$match-delta.d.ts +0 -3
- package/lib/aggregate/match/$match.d.ts +0 -3
- package/lib/aggregate/match/index.d.ts +0 -2
- package/lib/aggregate/mongo-stages.d.ts +0 -13
- package/lib/aggregate/out.d.ts +0 -37
- package/lib/aggregate/prefix.d.ts +0 -33
- package/lib/aggregate/raws.d.ts +0 -17
- package/lib/aggregate/set/$replace-with-each.d.ts +0 -13
- package/lib/aggregate/set/$set-delta.d.ts +0 -5
- package/lib/aggregate/set/$set.d.ts +0 -6
- package/lib/aggregate/set/index.d.ts +0 -1
- package/lib/aggregate/unwind/$unwind-delta.d.ts +0 -5
- package/lib/aggregate/unwind/index.d.ts +0 -6
- package/lib/boot/boot-simpl.d.ts +0 -14
- package/lib/boot/boot-utils.d.ts +0 -26
- package/lib/boot/boot.d.ts +0 -16
- package/lib/boot/first-stages.d.ts +0 -12
- package/lib/boot/index.d.ts +0 -3
- package/lib/boot/single.d.ts +0 -11
- package/lib/expression/arith.d.ts +0 -32
- package/lib/expression/array.d.ts +0 -30
- package/lib/expression/concat.d.ts +0 -34
- package/lib/expression/date.d.ts +0 -17
- package/lib/expression/expr-base.d.ts +0 -5
- package/lib/expression/index.d.ts +0 -7
- package/lib/expression/logic.d.ts +0 -23
- package/lib/expression/range.d.ts +0 -11
- package/lib/expression/val.d.ts +0 -25
- package/lib/field/field.d.ts +0 -25
- package/lib/field/index.d.ts +0 -1
- package/lib/machine.d.ts +0 -9
- package/lib/predicate/$eq.d.ts +0 -24
- package/lib/predicate/$expr.d.ts +0 -3
- package/lib/predicate/$in.d.ts +0 -2
- package/lib/predicate/index.d.ts +0 -3
- package/lib/predicate/utils.d.ts +0 -5
- package/lib/query/index.d.ts +0 -1
- package/lib/query/logic.d.ts +0 -11
- package/lib/stream/aggregate.d.ts +0 -7
- package/lib/types/accumulator.d.ts +0 -30
- package/lib/types/aggregate.d.ts +0 -9
- package/lib/types/expr.d.ts +0 -27
- package/lib/types/extern.d.ts +0 -3
- package/lib/types/index.d.ts +0 -8
- package/lib/types/lookup.d.ts +0 -19
- package/lib/types/machine.d.ts +0 -17
- package/lib/types/predicate.d.ts +0 -11
- package/lib/types/query.d.ts +0 -12
- package/lib/types/stream.d.ts +0 -69
- package/lib/update/index.d.ts +0 -1
- package/lib/update/updater.d.ts +0 -19
- package/lib/utils/before.d.ts +0 -3
- package/lib/utils/coll.d.ts +0 -5
- package/lib/utils/db-indexes.d.ts +0 -4
- package/lib/utils/guard.d.ts +0 -19
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/json.d.ts +0 -9
- package/lib/utils/log.d.ts +0 -1
- package/lib/utils/map-object.d.ts +0 -41
- package/lib/utils/merge/combiners.d.ts +0 -6
- package/lib/utils/merge/index.d.ts +0 -2
- package/lib/utils/merge/merge.d.ts +0 -7
- package/lib/utils/merge/next-winner.d.ts +0 -3
- package/lib/utils/merge/types.d.ts +0 -19
- package/lib/utils/merge/utils.d.ts +0 -4
- package/lib/utils/tear-down.d.ts +0 -2
- package/lib/watch.d.ts +0 -15
- package/test/mongodb.d.ts +0 -9
- package/test/uri.d.ts +0 -1
- package/types/class.d.ts +0 -1
- package/types/extern.d.ts +0 -3
- package/types/global.d.ts +0 -50
- package/types/hkt.d.ts +0 -56
- package/types/index.d.ts +0 -6
- package/types/json.d.ts +0 -54
- package/types/mongo.d.ts +0 -24
- package/types/view.d.ts +0 -35
package/index.d.ts
CHANGED
|
@@ -106,13 +106,15 @@ 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 IsDeleted = {
|
|
110
110
|
readonly deletedAt: Timestamp;
|
|
111
|
-
}
|
|
111
|
+
};
|
|
112
|
+
type DDel = IsDeleted & ID & TS;
|
|
112
113
|
type Del = O<DDel>;
|
|
113
|
-
type
|
|
114
|
+
type DeletedAt = {
|
|
114
115
|
readonly deletedAt?: Timestamp | null | undefined;
|
|
115
|
-
}
|
|
116
|
+
};
|
|
117
|
+
type D = O<DeletedAt & ID>;
|
|
116
118
|
type Model = D & TS;
|
|
117
119
|
type BA = 'before' | 'after';
|
|
118
120
|
type PreDelta<T, K extends BA = BA, E = unknown> = Rec<K, T> & E;
|
|
@@ -410,7 +412,7 @@ declare const $entries: <D extends O, V, C = unknown>(expr: Expr<Rec<string, Rec
|
|
|
410
412
|
|
|
411
413
|
type MergeInto<T extends O, Out extends O, E = unknown> = {
|
|
412
414
|
whenNotMatched: 'insert';
|
|
413
|
-
into: RWCollection<T, Out
|
|
415
|
+
into: RWCollection<T, Out> & E;
|
|
414
416
|
} | {
|
|
415
417
|
whenNotMatched: 'discard' | 'fail';
|
|
416
418
|
into: ReadonlyCollection<Out> & E;
|
|
@@ -431,7 +433,7 @@ type MergeArgs<T extends O, Out extends O, Ctx, In extends O> = {
|
|
|
431
433
|
stages: true;
|
|
432
434
|
into: RWCollection<In, Out>;
|
|
433
435
|
whenMatched: RawStages<unknown, Out, In, {
|
|
434
|
-
new:
|
|
436
|
+
new: T;
|
|
435
437
|
}>;
|
|
436
438
|
} | {
|
|
437
439
|
stages: 'ctx';
|
|
@@ -453,12 +455,14 @@ type Loose<Grp, VV, GG extends string> = Prepare<Grp, GG> & Par<V<VV, GG>>;
|
|
|
453
455
|
type Strict<Grp, VV, GG extends string, EE> = Prepare<Grp, GG> & V<VV, GG> & Omit<EE, IdAndTsKeys | GI$1<GG> | keyof V<VV, GG>>;
|
|
454
456
|
type V_Grp<VV, GG extends string, Grp> = Rec<GI$1<GG>, Grp> & V<VV, GG>;
|
|
455
457
|
type Extra<EE, VV, GG extends string> = Omit<EE, IdAndTsKeys | GI$1<GG> | keyof V<VV, GG>>;
|
|
458
|
+
type OrReplace<T, V> = T | Replace<T, V>;
|
|
459
|
+
type MergedInput<Out, VV, Grp, GG extends string, EE> = OrReplace<Replace<Replace<Out, V<VV, GG>>, Extra<EE, VV, GG>> & Model, TS & ID & V_Grp<VV, GG, Grp> & Extra<EE, VV, GG>>;
|
|
456
460
|
|
|
457
461
|
type Denied<GID = never> = keyof (TS & ID) | GID;
|
|
458
462
|
type GI<GG> = Exclude<GG, keyof TS>;
|
|
459
|
-
declare const $groupMerge: <T extends O, Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<GI<GG>>>>, out: MergeInto<Strict<Grp, V, GG, EE>, Out, WriteonlyCollection<
|
|
460
|
-
declare const $groupId: <T extends O, V extends O, EE = {}, Out extends Loose<string, V, "_id"> = Loose<string, V, "_id">>(id: Expr<string, T>, args: DeltaAccumulators<T, O & Omit<V, Denied>>, out: RWCollection<
|
|
461
|
-
declare const $group: <T extends O, Grp extends notArr, V extends O, EE = {}, Out extends Loose<Grp, V, "_grp"> = Loose<Grp, V, "_grp">>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<"_grp">>>, out: RWCollection<Strict<Grp, V, "_grp", EE>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | "_grp" | Exclude<keyof V, IdAndTsKeys | "_grp">>, Rec<"_grp", Grp> & Omit<V, IdAndTsKeys | "_grp">>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
|
|
463
|
+
declare const $groupMerge: <T extends O, Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<GI<GG>>>>, out: MergeInto<Strict<Grp, V, GG, EE>, Out, WriteonlyCollection<MergedInput<Out, V, Grp, GG, EE>>>, gid: AsLiteral<GI<GG>>, extra: ExprsExact<Extra<EE, V, GG>, V_Grp<V, GG, Grp>>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
|
|
464
|
+
declare const $groupId: <T extends O, V extends O, EE = {}, Out extends Loose<string, V, "_id"> = Loose<string, V, "_id">>(id: Expr<string, T>, args: DeltaAccumulators<T, O & Omit<V, Denied>>, out: RWCollection<MergedInput<Out, V, string, "_id", EE>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | keyof Omit<V, IdAndTsKeys>>, doc & Omit<V, IdAndTsKeys>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
465
|
+
declare const $group: <T extends O, Grp extends notArr, V extends O, EE = {}, Out extends Loose<Grp, V, "_grp"> = Loose<Grp, V, "_grp">>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<"_grp">>>, out: RWCollection<MergedInput<Out, V, Grp, "_grp", EE> | Strict<Grp, V, "_grp", EE>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | "_grp" | Exclude<keyof V, IdAndTsKeys | "_grp">>, Rec<"_grp", Grp> & Omit<V, IdAndTsKeys | "_grp">>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
|
|
462
466
|
|
|
463
467
|
type Params<As extends string, LQ extends O, RQ extends O, RE extends RQ, S extends notArr> = {
|
|
464
468
|
localField: Field<LQ, S>;
|
|
@@ -503,11 +507,19 @@ type ND$1 = {
|
|
|
503
507
|
readonly deletedAt?: null;
|
|
504
508
|
};
|
|
505
509
|
type SafeE$1<E> = Omit<E, `$${string}` | keyof ID>;
|
|
506
|
-
declare const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
510
|
+
declare const getWhenMatched: <Out extends Model, P extends Model, K extends keyof IsDeleted>(whenNotMatched: "discard" | "fail" | "insert") => RawStages<O, Out, Out | Replace<Out, P>, RORec<"new", Replace<P, RORec<K, Timestamp>>>>;
|
|
511
|
+
type MergeCollection<V extends O, Out extends Model> = {
|
|
512
|
+
coll: RWCollection<Out | Replace<Out, Patch<V>> | Replace<Patch<V>, IsDeleted>, Out>;
|
|
513
|
+
whenNotMatched: 'discard';
|
|
514
|
+
} | {
|
|
515
|
+
coll: RWCollection<Out | Replace<Out, Patch<V>>, Out>;
|
|
516
|
+
whenNotMatched: 'fail';
|
|
517
|
+
};
|
|
518
|
+
declare const $mergeId: <V extends O>() => <SourcePart extends doc, Out extends Model, E = unknown, EEE extends RORec<string, rawItem> = {}>(out: MergeCollection<V, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, id: Expr<string, OutInputE<TakeDoc<V>, E, null>>, ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>) => StreamRunnerParam<OutInputE<SourcePart, E>, "out">;
|
|
519
|
+
declare const $simpleMergePart: <V extends O>() => <Source extends doc, Out extends Model, EEE extends RORec<string, rawItem>>(out: MergeCollection<V, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>) => StreamRunnerParam<Source, "out">;
|
|
520
|
+
declare const $simpleMerge: <V extends O>() => <Source extends doc, Out extends Model>(out: RWCollection<Out | Replace<Out, Patch<V>> | Replace<Patch<V>, IsDeleted>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, whenNotMatched?: "fail" | "discard") => StreamRunnerParam<Source, "out">;
|
|
521
|
+
declare const $mergePart: <V extends O>() => <Out extends Model, SourcePart extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>) => StreamRunnerParam<Delta<SourcePart>, "out">;
|
|
522
|
+
declare const $merge: <V extends O>() => <Out extends Model, SourcePart extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>) => StreamRunnerParam<Delta<SourcePart>, "out">;
|
|
511
523
|
|
|
512
524
|
type ND = {
|
|
513
525
|
readonly deletedAt?: null;
|
|
@@ -519,6 +531,17 @@ declare const $simpleInsert: <T extends doc>(out: RWCollection<Merge<T, {}>>) =>
|
|
|
519
531
|
declare const $insertPart: <T extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Merge<T, EEE>>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<Delta<T>, "out">;
|
|
520
532
|
declare const $insert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
521
533
|
|
|
534
|
+
declare const log: (...args: unknown[]) => void;
|
|
535
|
+
|
|
536
|
+
declare const createIndex: (collection: {
|
|
537
|
+
readonly createIndex: Collection["createIndex"];
|
|
538
|
+
}, indexSpec: IndexSpecification, options?: CreateIndexesOptions) => Promise<void>;
|
|
539
|
+
|
|
540
|
+
declare const noop: () => void;
|
|
541
|
+
declare const map1: <K extends string, Im>(k: AsLiteral<K>, to: Im) => { readonly [P in K]: [P, Im]; } & {
|
|
542
|
+
readonly [_: string]: [K, Im];
|
|
543
|
+
};
|
|
544
|
+
|
|
522
545
|
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>;
|
|
523
546
|
|
|
524
547
|
type DeltaPipe<Q extends O, T extends Q, F extends HKT<O2>, G extends HKT<O3>> = {
|
|
@@ -608,7 +631,7 @@ declare const first: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>
|
|
|
608
631
|
declare const firstSure: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T, D, C>;
|
|
609
632
|
declare const last: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
|
|
610
633
|
type NullToOBJ<N extends null> = N extends null ? O : N;
|
|
611
|
-
declare const mergeObjects: <T1, T2, D, C = unknown, N extends null = never>(
|
|
634
|
+
declare const mergeObjects: <T1, T2, D, C = unknown, N extends null = never>(...exprs: readonly [Expr<T1 | N, D, C>, ...[...Expr<T1 | T2 | N, D, C>[], Expr<T2, D, C>]]) => Expr<(T1 | NullToOBJ<N>) & T2, D, C>;
|
|
612
635
|
declare const anyElementTrue: <D, C = unknown>(expr: Expr<Arr<boolean>, D, C>) => Expr<boolean, D, C>;
|
|
613
636
|
type Reduce<T, V> = RORec<'value', V> & RORec<'this', T>;
|
|
614
637
|
declare const $reduce: <T, V, D, C>(input: Expr<Arr<T>, D, C>, initialValue: Expr<V, D, C>, inExpr: Expr<V, D, C & Reduce<T, V>>) => Expr<V, D, C>;
|
|
@@ -706,19 +729,8 @@ declare const $and: Combiner;
|
|
|
706
729
|
declare const $nor: Combiner;
|
|
707
730
|
declare const $or: Combiner;
|
|
708
731
|
|
|
709
|
-
declare const log: (...args: unknown[]) => void;
|
|
710
|
-
|
|
711
|
-
declare const createIndex: (collection: {
|
|
712
|
-
readonly createIndex: Collection["createIndex"];
|
|
713
|
-
}, indexSpec: IndexSpecification, options?: CreateIndexesOptions) => Promise<void>;
|
|
714
|
-
|
|
715
|
-
declare const noop: () => void;
|
|
716
|
-
declare const map1: <K extends string, Im>(k: AsLiteral<K>, to: Im) => { readonly [P in K]: [P, Im]; } & {
|
|
717
|
-
readonly [_: string]: [K, Im];
|
|
718
|
-
};
|
|
719
|
-
|
|
720
732
|
declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Promise<Document>;
|
|
721
733
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
722
734
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
723
735
|
|
|
724
|
-
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, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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, type jsonPrim, 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 };
|
|
736
|
+
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, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $sum, $type, $unwind, $unwindDelta, type Accumulators, type Arr, type AsLiteral, type Delta, type DeltaAccumulator, type DeltaAccumulators, type ExactKeys, 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 Patch, 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, getWhenMatched, gt, gte, inArray, isArray, ite, type jsonPrim, 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
|
@@ -544,134 +544,6 @@ const subGroup = (id, args, addGrp) => {
|
|
|
544
544
|
.with(replaceWith(field(addGrp(mapExact(args, (_, k) => $getField(root().expr(), k)))))).stages;
|
|
545
545
|
};
|
|
546
546
|
|
|
547
|
-
const subUpdater = (a, f) => ({ raw: (g) => a.raw(g.with(f)) });
|
|
548
|
-
const set = () => (fields) => ({
|
|
549
|
-
raw: f => {
|
|
550
|
-
return Object.entries(mapExactToObject0(fields, v => v)).flatMap(([k, v]) => v.raw(f).map(([l, v]) => [`.${k}${l}`, v]));
|
|
551
|
-
},
|
|
552
|
-
});
|
|
553
|
-
const weaken = (updater) => ({ raw: f => updater.raw(f) });
|
|
554
|
-
const to = (expr) => ({
|
|
555
|
-
raw: f => [['', expr.raw(f).get()]],
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
const dbcoll = (x) => ({
|
|
559
|
-
db: x.dbName,
|
|
560
|
-
coll: x.collectionName,
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
const $merge_ = ({ into, on, whenNotMatched, ...notMatched }) => asStages([
|
|
564
|
-
{
|
|
565
|
-
$merge: {
|
|
566
|
-
into: dbcoll(into),
|
|
567
|
-
on: on.str(),
|
|
568
|
-
...(whenNotMatched && { whenNotMatched }),
|
|
569
|
-
...(notMatched.stages && {
|
|
570
|
-
whenMatched: notMatched.whenMatched,
|
|
571
|
-
...(notMatched.stages === 'ctx' && { let: rawVars(notMatched.vars, root()) }),
|
|
572
|
-
}),
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
]);
|
|
576
|
-
const $merge2 = (args) => $merge_(args);
|
|
577
|
-
|
|
578
|
-
const subMerge = (args, out, gid, extra, idPrefix, first) => {
|
|
579
|
-
const doubleReplace = (x) => x;
|
|
580
|
-
const mergeAggregates = $set_(set()(mapExact0(args, (v, k) => to(first
|
|
581
|
-
? ctx()('new').of(k).expr()
|
|
582
|
-
: v.merge(root().of(k).expr(), ctx()('new').of(k).expr())))));
|
|
583
|
-
const gidPath = root().of(gid).expr();
|
|
584
|
-
const mapId = (k, v) => map1(k, v);
|
|
585
|
-
const F1 = {
|
|
586
|
-
_id: ['_id', to(idPrefix ? concat$1(val(idPrefix), $rand) : $rand)],
|
|
587
|
-
touchedAt: ['touchedAt', to(current)],
|
|
588
|
-
};
|
|
589
|
-
const F2 = mapId(gid, to(gidPath));
|
|
590
|
-
const addExtraAndMerge = {
|
|
591
|
-
...mapExact0(extra, to),
|
|
592
|
-
...F1,
|
|
593
|
-
...F2,
|
|
594
|
-
};
|
|
595
|
-
const addTSAndExtra = {
|
|
596
|
-
...mapExact0(extra, to),
|
|
597
|
-
touchedAt: ['touchedAt', to(current)],
|
|
598
|
-
};
|
|
599
|
-
const updater = set()(addTSAndExtra);
|
|
600
|
-
return (link()
|
|
601
|
-
.with($set_(set()(addExtraAndMerge)))
|
|
602
|
-
.with($merge_({
|
|
603
|
-
...out,
|
|
604
|
-
on: root().of(gid),
|
|
605
|
-
vars: { new: ['new', root().expr()] },
|
|
606
|
-
stages: 'ctx',
|
|
607
|
-
whenMatched: link()
|
|
608
|
-
.with(mergeAggregates)
|
|
609
|
-
.with(doubleReplace($set_(updater))).stages,
|
|
610
|
-
})).stages);
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
const addGrp = (gid) => (expr) => {
|
|
614
|
-
const omit = omitPick();
|
|
615
|
-
return omit.backward(mergeExpr(omit.forward(expr), map1(gid, root().of('_id').expr())));
|
|
616
|
-
};
|
|
617
|
-
const $groupMerge = (id, args, out, gid, extra, idPrefix = '') => ({
|
|
618
|
-
raw: (first) => link()
|
|
619
|
-
.with(subGroup(id, args, addGrp(gid)))
|
|
620
|
-
.with(subMerge(args, out, gid, extra, idPrefix, first)).stages,
|
|
621
|
-
teardown: c => c(out.whenNotMatched === 'insert'
|
|
622
|
-
? {
|
|
623
|
-
collection: out.into,
|
|
624
|
-
method: 'deleteMany',
|
|
625
|
-
params: [{}],
|
|
626
|
-
}
|
|
627
|
-
: {
|
|
628
|
-
collection: out.into,
|
|
629
|
-
method: 'updateMany',
|
|
630
|
-
params: [
|
|
631
|
-
{},
|
|
632
|
-
[
|
|
633
|
-
{
|
|
634
|
-
$unset: Object.keys({
|
|
635
|
-
...mapExactToObject(extra, () => 1),
|
|
636
|
-
...mapExactToObject(args, () => 1),
|
|
637
|
-
}),
|
|
638
|
-
},
|
|
639
|
-
],
|
|
640
|
-
],
|
|
641
|
-
}),
|
|
642
|
-
});
|
|
643
|
-
const $groupId = (id, args, out, extra) => $groupMerge(id, args, { into: out, whenNotMatched: 'fail' }, '_id', extra);
|
|
644
|
-
const $group = (id, args, out, extra, idPrefix = '') => $groupMerge(id, args, { into: out, whenNotMatched: 'insert' }, '_grp', extra, idPrefix);
|
|
645
|
-
|
|
646
|
-
const deltaExpr = (expr) => (field) => {
|
|
647
|
-
return ite(eqTyped($ifNull(root().of(field).expr(), nil), nil), nil, expr(field));
|
|
648
|
-
};
|
|
649
|
-
const $setEach1 = (updater, dict) => {
|
|
650
|
-
return $set1(set()(mapExact1(dict, updater)));
|
|
651
|
-
};
|
|
652
|
-
const $setEach = (updater, dict) => $setEach1(updater, dict)(root);
|
|
653
|
-
const $replaceWithEach1 = (t) => {
|
|
654
|
-
return $setEach(k => to(t(k)), {
|
|
655
|
-
after: ['after', 'after'],
|
|
656
|
-
before: ['before', 'before'],
|
|
657
|
-
});
|
|
658
|
-
};
|
|
659
|
-
const $replaceWithEach = (expr) => $replaceWithEach1(deltaExpr(expr));
|
|
660
|
-
|
|
661
|
-
const $replaceWithDelta = (expr) => $replaceWithEach((field) => sub(expr, root().of(field)));
|
|
662
|
-
const $setDelta = (updater) => {
|
|
663
|
-
const dict = {
|
|
664
|
-
after1: ['after1', 'after'],
|
|
665
|
-
before1: ['before1', 'before'],
|
|
666
|
-
};
|
|
667
|
-
const update = (k) => subUpdater(weaken(updater), root().of(k));
|
|
668
|
-
return link()
|
|
669
|
-
.with($setEach(k => to(root().of(k).expr()), dict))
|
|
670
|
-
.with($setEach(update, dict))
|
|
671
|
-
.with($replaceWithEach(field => root().of(`${field}1`).expr()))
|
|
672
|
-
.with($setEach(k => to(nil), dict)).stages;
|
|
673
|
-
};
|
|
674
|
-
|
|
675
547
|
const dayAndMonthPart = (date) => asExpr({
|
|
676
548
|
raw: f => asExprRaw({ $dateToString: { date: date.raw(f).get(), format: '%m-%d' } }),
|
|
677
549
|
});
|
|
@@ -908,6 +780,217 @@ const $map0 = ({ as, expr, input, }) => asExpr({
|
|
|
908
780
|
const $map1 = (ex, map) => $map0({ input: ex, as: 'item', expr: map(ctx()('item')) });
|
|
909
781
|
const $map = (ex, map) => $map1(ex, i => map(i.expr()));
|
|
910
782
|
|
|
783
|
+
const subUpdater = (a, f) => ({ raw: (g) => a.raw(g.with(f)) });
|
|
784
|
+
const set = () => (fields) => ({
|
|
785
|
+
raw: f => {
|
|
786
|
+
return Object.entries(mapExactToObject0(fields, v => v)).flatMap(([k, v]) => v.raw(f).map(([l, v]) => [`.${k}${l}`, v]));
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
const weaken = (updater) => ({ raw: f => updater.raw(f) });
|
|
790
|
+
const to = (expr) => ({
|
|
791
|
+
raw: f => [['', expr.raw(f).get()]],
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
const dbcoll = (x) => ({
|
|
795
|
+
db: x.dbName,
|
|
796
|
+
coll: x.collectionName,
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
const $merge_ = ({ into, on, whenNotMatched, ...notMatched }) => asStages([
|
|
800
|
+
{
|
|
801
|
+
$merge: {
|
|
802
|
+
into: dbcoll(into),
|
|
803
|
+
on: on.str(),
|
|
804
|
+
...(whenNotMatched && { whenNotMatched }),
|
|
805
|
+
...(notMatched.stages && {
|
|
806
|
+
whenMatched: notMatched.whenMatched,
|
|
807
|
+
...(notMatched.stages === 'ctx' && { let: rawVars(notMatched.vars, root()) }),
|
|
808
|
+
}),
|
|
809
|
+
},
|
|
810
|
+
},
|
|
811
|
+
]);
|
|
812
|
+
const $merge2 = (args) => $merge_(args);
|
|
813
|
+
|
|
814
|
+
const getWhenMatched = (whenNotMatched) => {
|
|
815
|
+
const setDeleted = whenNotMatched === 'discard';
|
|
816
|
+
const orNull = (e) => (setDeleted ? $ifNull(e, nil) : e);
|
|
817
|
+
const preMergeOld = setDeleted
|
|
818
|
+
? mergeObjects(root().of('old').expr(), field({
|
|
819
|
+
deletedAt: ['deletedAt', orNull(root().of('old').of('deletedAt').expr())],
|
|
820
|
+
touchedAt: ['touchedAt', root().of('merged').of('touchedAt').expr()],
|
|
821
|
+
}))
|
|
822
|
+
: root().of('old').expr();
|
|
823
|
+
const same = eq(preMergeOld)(root().of('merged').expr());
|
|
824
|
+
const newOrOld = whenNotMatched ===
|
|
825
|
+
'insert'
|
|
826
|
+
? ctx()('new')
|
|
827
|
+
: root();
|
|
828
|
+
const merged = mergeObjects(root().expr(), ctx()('new').expr(), field({
|
|
829
|
+
deletedAt: ['deletedAt', orNull(newOrOld.of('deletedAt').expr())],
|
|
830
|
+
}));
|
|
831
|
+
return link()
|
|
832
|
+
.with($replaceWith_(field({
|
|
833
|
+
old: ['old', root().expr()],
|
|
834
|
+
merged: ['merged', merged],
|
|
835
|
+
})))
|
|
836
|
+
.with($replaceWith_(ite(same, root().of('old').expr(), root().of('merged').expr()))).stages;
|
|
837
|
+
};
|
|
838
|
+
const $mergeX = (out, keys, f, map, ext) => {
|
|
839
|
+
const patch = mapExact(keys, v => sub(v, f));
|
|
840
|
+
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
841
|
+
const setDeleted = out.whenNotMatched === 'discard';
|
|
842
|
+
const replacer = map(field(omitPick().backward(spread(patch, {
|
|
843
|
+
_id: ['_id', f.of('_id').expr()],
|
|
844
|
+
touchedAt: ['touchedAt', current],
|
|
845
|
+
}))));
|
|
846
|
+
const sss = setDeleted
|
|
847
|
+
? link()
|
|
848
|
+
.with($set_(set()({
|
|
849
|
+
deletedAt: ['deletedAt', to(current)],
|
|
850
|
+
})))
|
|
851
|
+
.with($merge_({
|
|
852
|
+
into: out.coll,
|
|
853
|
+
on: root().of('_id'),
|
|
854
|
+
whenNotMatched: 'insert',
|
|
855
|
+
stages: true,
|
|
856
|
+
whenMatched: getWhenMatched(out.whenNotMatched),
|
|
857
|
+
})).stages
|
|
858
|
+
: link().with($merge_({
|
|
859
|
+
into: out.coll,
|
|
860
|
+
on: root().of('_id'),
|
|
861
|
+
whenNotMatched: 'fail',
|
|
862
|
+
stages: true,
|
|
863
|
+
whenMatched: getWhenMatched(out.whenNotMatched),
|
|
864
|
+
})).stages;
|
|
865
|
+
const teardown = (coll) => ({
|
|
866
|
+
collection: coll,
|
|
867
|
+
method: 'updateMany',
|
|
868
|
+
params: [
|
|
869
|
+
filter,
|
|
870
|
+
[
|
|
871
|
+
{
|
|
872
|
+
$unset: Object.keys(mapExactToObject(keys, () => 1)),
|
|
873
|
+
},
|
|
874
|
+
],
|
|
875
|
+
],
|
|
876
|
+
});
|
|
877
|
+
return {
|
|
878
|
+
raw: (first) => link().with($replaceWith_(replacer)).with(sss)
|
|
879
|
+
.stages,
|
|
880
|
+
teardown: c => (setDeleted ? c(teardown(out.coll)) : c(teardown(out.coll))),
|
|
881
|
+
};
|
|
882
|
+
};
|
|
883
|
+
const $mergeId = () => (out, keys, id, ext) => {
|
|
884
|
+
const omRORec = omitRORec();
|
|
885
|
+
return $mergeX(out, keys, root().of('after'), or => {
|
|
886
|
+
return ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
|
|
887
|
+
_id: ['_id', id],
|
|
888
|
+
touchedAt: ['touchedAt', current],
|
|
889
|
+
}))), or);
|
|
890
|
+
}, ext);
|
|
891
|
+
};
|
|
892
|
+
const $simpleMergePart = () => (out, keys, ext) => $mergeX(out, keys, root(), id$1, ext);
|
|
893
|
+
const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX({ coll: out, whenNotMatched }, keys, root(), id$1, {});
|
|
894
|
+
const $mergePart = () => (out, keys, ext) => $mergeId()({ coll: out, whenNotMatched: 'fail' }, keys, assertNotNull$1(root().of('before').of('_id').expr()), ext);
|
|
895
|
+
const $merge = () => (out, keys) => $mergePart()(out, keys, {});
|
|
896
|
+
const assertNotNull$1 = (expr) => expr;
|
|
897
|
+
|
|
898
|
+
const subMerge = (args, out, gid, extra, idPrefix, first) => {
|
|
899
|
+
const e = extra;
|
|
900
|
+
const mergeAggregates = $set_(set()(mapExact0(args, (v, k) => to(first
|
|
901
|
+
? ctx()('new').of(k).expr()
|
|
902
|
+
: v.merge(root().of(k).expr(), ctx()('new').of(k).expr())))));
|
|
903
|
+
const gidPath = root().of(gid).expr();
|
|
904
|
+
const mapId = (k, v) => map1(k, v);
|
|
905
|
+
const F1 = {
|
|
906
|
+
_id: ['_id', to(idPrefix ? concat$1(val(idPrefix), $rand) : $rand)],
|
|
907
|
+
touchedAt: ['touchedAt', to(current)],
|
|
908
|
+
};
|
|
909
|
+
const F2 = mapId(gid, to(gidPath));
|
|
910
|
+
const addExtraAndMerge = {
|
|
911
|
+
...mapExact0(extra, to),
|
|
912
|
+
...F1,
|
|
913
|
+
...F2,
|
|
914
|
+
};
|
|
915
|
+
const addExtra = mapExact0(e, to);
|
|
916
|
+
const updater = set()(addExtra);
|
|
917
|
+
return link()
|
|
918
|
+
.with($set_(set()(addExtraAndMerge)))
|
|
919
|
+
.with($merge_({
|
|
920
|
+
into: null,
|
|
921
|
+
whenNotMatched: 'fail',
|
|
922
|
+
on: root().of(gid),
|
|
923
|
+
vars: { new: ['new', root().expr()] },
|
|
924
|
+
stages: 'ctx',
|
|
925
|
+
whenMatched: link()
|
|
926
|
+
.with(mergeAggregates)
|
|
927
|
+
.with($set_(updater))
|
|
928
|
+
.with(getWhenMatched(out.whenNotMatched)).stages,
|
|
929
|
+
})).stages;
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
const addGrp = (gid) => (expr) => {
|
|
933
|
+
const omit = omitPick();
|
|
934
|
+
return omit.backward(mergeExpr(omit.forward(expr), map1(gid, root().of('_id').expr())));
|
|
935
|
+
};
|
|
936
|
+
const $groupMerge = (id, args, out, gid, extra, idPrefix = '') => ({
|
|
937
|
+
raw: (first) => link()
|
|
938
|
+
.with(subGroup(id, args, addGrp(gid)))
|
|
939
|
+
.with(subMerge(args, out, gid, extra, idPrefix, first)).stages,
|
|
940
|
+
teardown: c => c(out.whenNotMatched === 'insert'
|
|
941
|
+
? {
|
|
942
|
+
collection: out.into,
|
|
943
|
+
method: 'deleteMany',
|
|
944
|
+
params: [{}],
|
|
945
|
+
}
|
|
946
|
+
: {
|
|
947
|
+
collection: out.into,
|
|
948
|
+
method: 'updateMany',
|
|
949
|
+
params: [
|
|
950
|
+
{},
|
|
951
|
+
[
|
|
952
|
+
{
|
|
953
|
+
$unset: Object.keys({
|
|
954
|
+
...mapExactToObject(extra, () => 1),
|
|
955
|
+
...mapExactToObject(args, () => 1),
|
|
956
|
+
}),
|
|
957
|
+
},
|
|
958
|
+
],
|
|
959
|
+
],
|
|
960
|
+
}),
|
|
961
|
+
});
|
|
962
|
+
const $groupId = (id, args, out, extra) => $groupMerge(id, args, { into: out, whenNotMatched: 'fail' }, '_id', extra);
|
|
963
|
+
const $group = (id, args, out, extra, idPrefix = '') => $groupMerge(id, args, { into: out, whenNotMatched: 'insert' }, '_grp', extra, idPrefix);
|
|
964
|
+
|
|
965
|
+
const deltaExpr = (expr) => (field) => {
|
|
966
|
+
return ite(eqTyped($ifNull(root().of(field).expr(), nil), nil), nil, expr(field));
|
|
967
|
+
};
|
|
968
|
+
const $setEach1 = (updater, dict) => {
|
|
969
|
+
return $set1(set()(mapExact1(dict, updater)));
|
|
970
|
+
};
|
|
971
|
+
const $setEach = (updater, dict) => $setEach1(updater, dict)(root);
|
|
972
|
+
const $replaceWithEach1 = (t) => {
|
|
973
|
+
return $setEach(k => to(t(k)), {
|
|
974
|
+
after: ['after', 'after'],
|
|
975
|
+
before: ['before', 'before'],
|
|
976
|
+
});
|
|
977
|
+
};
|
|
978
|
+
const $replaceWithEach = (expr) => $replaceWithEach1(deltaExpr(expr));
|
|
979
|
+
|
|
980
|
+
const $replaceWithDelta = (expr) => $replaceWithEach((field) => sub(expr, root().of(field)));
|
|
981
|
+
const $setDelta = (updater) => {
|
|
982
|
+
const dict = {
|
|
983
|
+
after1: ['after1', 'after'],
|
|
984
|
+
before1: ['before1', 'before'],
|
|
985
|
+
};
|
|
986
|
+
const update = (k) => subUpdater(weaken(updater), root().of(k));
|
|
987
|
+
return link()
|
|
988
|
+
.with($setEach(k => to(root().of(k).expr()), dict))
|
|
989
|
+
.with($setEach(update, dict))
|
|
990
|
+
.with($replaceWithEach(field => root().of(`${field}1`).expr()))
|
|
991
|
+
.with($setEach(k => to(nil), dict)).stages;
|
|
992
|
+
};
|
|
993
|
+
|
|
911
994
|
const operator = () => (op) => (operand) => {
|
|
912
995
|
return {
|
|
913
996
|
raw: { [op]: operand },
|
|
@@ -1365,86 +1448,6 @@ const $replaceWith = (expr) => ({
|
|
|
1365
1448
|
lin: $replaceWith_(expr),
|
|
1366
1449
|
});
|
|
1367
1450
|
|
|
1368
|
-
const $mergeX = (out, keys, f, map, whenNotMatched = 'fail', ext) => {
|
|
1369
|
-
const patch = mapExact(keys, v => sub(v, f));
|
|
1370
|
-
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
1371
|
-
const setDeleted = whenNotMatched === 'discard';
|
|
1372
|
-
const replacer = map(field(omitPick().backward(spread(patch, {
|
|
1373
|
-
_id: ['_id', f.of('_id').expr()],
|
|
1374
|
-
touchedAt: ['touchedAt', current],
|
|
1375
|
-
deletedAt: [setDeleted ? 'deletedAt' : 'touchedAt', current],
|
|
1376
|
-
}))));
|
|
1377
|
-
return {
|
|
1378
|
-
raw: (first) => link()
|
|
1379
|
-
.with($replaceWith_(replacer))
|
|
1380
|
-
.with($merge_({
|
|
1381
|
-
into: out,
|
|
1382
|
-
on: root().of('_id'),
|
|
1383
|
-
whenNotMatched: whenNotMatched === 'fail' ? 'fail' : 'insert',
|
|
1384
|
-
stages: true,
|
|
1385
|
-
whenMatched: asStages([
|
|
1386
|
-
{
|
|
1387
|
-
$replaceWith: {
|
|
1388
|
-
old: '$$ROOT',
|
|
1389
|
-
merged: {
|
|
1390
|
-
$mergeObjects: [
|
|
1391
|
-
'$$ROOT',
|
|
1392
|
-
'$$new',
|
|
1393
|
-
...(setDeleted ? [{ deletedAt: { $ifNull: ['$deletedAt', null] } }] : []),
|
|
1394
|
-
],
|
|
1395
|
-
},
|
|
1396
|
-
},
|
|
1397
|
-
},
|
|
1398
|
-
{
|
|
1399
|
-
$replaceWith: {
|
|
1400
|
-
$cond: {
|
|
1401
|
-
if: {
|
|
1402
|
-
$eq: [
|
|
1403
|
-
{
|
|
1404
|
-
$mergeObjects: [
|
|
1405
|
-
'$old',
|
|
1406
|
-
{ deletedAt: { $ifNull: ['$old.deletedAt', null] } },
|
|
1407
|
-
],
|
|
1408
|
-
},
|
|
1409
|
-
{ $mergeObjects: ['$merged', { touchedAt: '$old.touchedAt' }] },
|
|
1410
|
-
],
|
|
1411
|
-
},
|
|
1412
|
-
then: '$old',
|
|
1413
|
-
else: '$merged',
|
|
1414
|
-
},
|
|
1415
|
-
},
|
|
1416
|
-
},
|
|
1417
|
-
]),
|
|
1418
|
-
})).stages,
|
|
1419
|
-
teardown: c => c({
|
|
1420
|
-
collection: out,
|
|
1421
|
-
method: 'updateMany',
|
|
1422
|
-
params: [
|
|
1423
|
-
filter,
|
|
1424
|
-
[
|
|
1425
|
-
{
|
|
1426
|
-
$unset: Object.keys(mapExactToObject(keys, () => 1)),
|
|
1427
|
-
},
|
|
1428
|
-
],
|
|
1429
|
-
],
|
|
1430
|
-
}),
|
|
1431
|
-
};
|
|
1432
|
-
};
|
|
1433
|
-
const $mergeId = () => (out, keys, id, ext, whenNotMatched) => {
|
|
1434
|
-
const omRORec = omitRORec();
|
|
1435
|
-
return $mergeX(out, keys, root().of('after'), or => {
|
|
1436
|
-
return ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
|
|
1437
|
-
_id: ['_id', id],
|
|
1438
|
-
touchedAt: ['touchedAt', current],
|
|
1439
|
-
}))), or);
|
|
1440
|
-
}, whenNotMatched, ext);
|
|
1441
|
-
};
|
|
1442
|
-
const $simpleMergePart = () => (out, keys, whenNotMatched, ext) => $mergeX(out, keys, root(), id$1, whenNotMatched, ext);
|
|
1443
|
-
const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX(out, keys, root(), id$1, whenNotMatched, {});
|
|
1444
|
-
const $mergePart = () => (out, keys, ext, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), ext, whenNotMatched);
|
|
1445
|
-
const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergePart()(out, keys, {}, whenNotMatched);
|
|
1446
|
-
const assertNotNull$1 = (expr) => expr;
|
|
1447
|
-
|
|
1448
1451
|
const $insertX = (out, expr, map, ext, extExpr) => {
|
|
1449
1452
|
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
1450
1453
|
return {
|
|
@@ -1467,23 +1470,7 @@ const $insertX = (out, expr, map, ext, extExpr) => {
|
|
|
1467
1470
|
into: out,
|
|
1468
1471
|
on: root().of('_id'),
|
|
1469
1472
|
stages: true,
|
|
1470
|
-
whenMatched:
|
|
1471
|
-
{ $replaceWith: { old: '$$ROOT', merged: { $mergeObjects: ['$$ROOT', '$$new'] } } },
|
|
1472
|
-
{
|
|
1473
|
-
$replaceWith: {
|
|
1474
|
-
$cond: {
|
|
1475
|
-
if: {
|
|
1476
|
-
$eq: [
|
|
1477
|
-
'$old',
|
|
1478
|
-
{ $mergeObjects: ['$merged', { touchedAt: '$old.touchedAt' }] },
|
|
1479
|
-
],
|
|
1480
|
-
},
|
|
1481
|
-
then: '$old',
|
|
1482
|
-
else: '$merged',
|
|
1483
|
-
},
|
|
1484
|
-
},
|
|
1485
|
-
},
|
|
1486
|
-
]),
|
|
1473
|
+
whenMatched: getWhenMatched('insert'),
|
|
1487
1474
|
whenNotMatched: 'insert',
|
|
1488
1475
|
})).stages;
|
|
1489
1476
|
},
|
|
@@ -2007,4 +1994,4 @@ const makeCol = async (docs, database, name) => {
|
|
|
2007
1994
|
}
|
|
2008
1995
|
};
|
|
2009
1996
|
|
|
2010
|
-
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, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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 };
|
|
1997
|
+
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, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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, getWhenMatched, 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 };
|