@omegup/msync 0.0.32-test1 → 0.0.32-test3
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 +30 -25
- package/index.esm.js +14 -7
- package/index.js +14 -6
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -450,6 +450,31 @@ declare const $groupMerge: <T extends O, Grp extends notArr, V extends O, GG ext
|
|
|
450
450
|
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<Replace<Out, Strict<string, V, "_id", EE>>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | keyof Omit<V, IdAndTsKeys>>, doc & Omit<V, IdAndTsKeys>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
451
451
|
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" | keyof Omit<V, IdAndTsKeys | "_grp">>, Rec<"_grp", Grp> & Omit<V, IdAndTsKeys | "_grp">>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
|
|
452
452
|
|
|
453
|
+
declare const size: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<number, D, C>;
|
|
454
|
+
declare const filterDefined: <T, D, C = unknown>(expr: Expr<Arr<T | N>, D, C>) => Expr<Arr<T>, D, C>;
|
|
455
|
+
declare const filter: <T, D, K extends string, C = unknown>({ as, cond, expr, limit, }: {
|
|
456
|
+
expr: Expr<Arr<T>, D, C>;
|
|
457
|
+
as: K;
|
|
458
|
+
cond: Expr<unknown, D, C & RORec<K, T>>;
|
|
459
|
+
limit?: Expr<number, D, C>;
|
|
460
|
+
}) => Expr<Arr<T>, D, C>;
|
|
461
|
+
declare const sortArray: <T, D, C, K extends keyof T>({ sortBy, expr, order, }: {
|
|
462
|
+
expr: Expr<Arr<T>, D, C>;
|
|
463
|
+
sortBy: K;
|
|
464
|
+
order?: 1 | -1;
|
|
465
|
+
}) => Expr<Arr<T>, D, C>;
|
|
466
|
+
declare const isArray: <T extends notArr, D, C, F extends HKT<T | Arr<T>>>(expr: Expr<T | Arr<T>, D & (App<F, T> | App<F, Arr<T>>), C>) => BoolExpr<D & App<F, Arr<T>>, D & App<F, T>, C>;
|
|
467
|
+
declare const array: <T, D, C = unknown>(...exprs: Expr<T, D, C>[]) => Expr<Arr<T>, D, C>;
|
|
468
|
+
declare const concatArray: <T, D, C>(...exprs: Expr<Arr<T>, D, C>[]) => Expr<Arr<T>, D, C>;
|
|
469
|
+
declare const first: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
|
|
470
|
+
declare const firstSure: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T, D, C>;
|
|
471
|
+
declare const last: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
|
|
472
|
+
type NullToOBJ<N extends null> = N extends null ? O : N;
|
|
473
|
+
declare const mergeObjects: <T1, T2, D, C = unknown, N extends null = never>(exprs_0: Expr<T1 | N, D, C>, exprs_1: Expr<T2, D, C>) => Expr<(T1 | NullToOBJ<N>) & T2, D, C>;
|
|
474
|
+
declare const inArray: <T, D, C = unknown>(exprs_0: Expr<T, D, C>, exprs_1: Expr<Arr<T>, D, C>) => Expr<boolean, D, C>;
|
|
475
|
+
declare const slice: <T, D, C>(array: Expr<Arr<T>, D, C>, start: Expr<number, D, C>, end: Expr<number, D, C>) => Expr<Arr<T>, D, C>;
|
|
476
|
+
declare const except: <T, D, C>(a: Expr<Arr<T>, D, C>, b: Expr<Arr<T>, D, C>) => Expr<Arr<T>, D, C>;
|
|
477
|
+
|
|
453
478
|
type Params<As extends string, LQ extends O, RQ extends O, RE extends RQ, S extends notArr> = {
|
|
454
479
|
localField: Field<LQ, S>;
|
|
455
480
|
foreignField: Field<RQ, S>;
|
|
@@ -457,6 +482,10 @@ type Params<As extends string, LQ extends O, RQ extends O, RE extends RQ, S exte
|
|
|
457
482
|
as: AsLiteral<As>;
|
|
458
483
|
};
|
|
459
484
|
declare const $lookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr>(p: Params<As, LQ, RQ, RE, S>) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ, LE & RORec<As, RE>>;
|
|
485
|
+
declare const $outerLookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr, LNull extends null = never, RNull extends null = never>(p: Params<As, LQ, RQ, RE, S>, outer: {
|
|
486
|
+
left?: LNull;
|
|
487
|
+
right?: RNull;
|
|
488
|
+
}) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ | NullToOBJ<RNull>, (LE | NullToOBJ<RNull>) & RORec<As, RE | LNull>>;
|
|
460
489
|
|
|
461
490
|
declare const $matchDelta: <T extends doc>(query: Expr<boolean, T>) => RawStages<unknown, Delta<T>, Delta<T>, unknown, number>;
|
|
462
491
|
|
|
@@ -548,30 +577,6 @@ declare function floor<D, C>(expr: Expr<Num, D, C>): Expr<Num, D, C>;
|
|
|
548
577
|
declare function ceil<D, C>(expr: Expr<number, D, C>): Expr<number, D, C>;
|
|
549
578
|
declare function ceil<D, C>(expr: Expr<Num, D, C>): Expr<Num, D, C>;
|
|
550
579
|
|
|
551
|
-
declare const size: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<number, D, C>;
|
|
552
|
-
declare const filterDefined: <T, D, C = unknown>(expr: Expr<Arr<T | N>, D, C>) => Expr<Arr<T>, D, C>;
|
|
553
|
-
declare const filter: <T, D, K extends string, C = unknown>({ as, cond, expr, limit, }: {
|
|
554
|
-
expr: Expr<Arr<T>, D, C>;
|
|
555
|
-
as: K;
|
|
556
|
-
cond: Expr<unknown, D, C & RORec<K, T>>;
|
|
557
|
-
limit?: Expr<number, D, C>;
|
|
558
|
-
}) => Expr<Arr<T>, D, C>;
|
|
559
|
-
declare const sortArray: <T, D, C, K extends keyof T>({ sortBy, expr, order, }: {
|
|
560
|
-
expr: Expr<Arr<T>, D, C>;
|
|
561
|
-
sortBy: K;
|
|
562
|
-
order?: 1 | -1;
|
|
563
|
-
}) => Expr<Arr<T>, D, C>;
|
|
564
|
-
declare const isArray: <T extends notArr, D, C, F extends HKT<T | Arr<T>>>(expr: Expr<T | Arr<T>, D & (App<F, T> | App<F, Arr<T>>), C>) => BoolExpr<D & App<F, Arr<T>>, D & App<F, T>, C>;
|
|
565
|
-
declare const array: <T, D, C = unknown>(...exprs: Expr<T, D, C>[]) => Expr<Arr<T>, D, C>;
|
|
566
|
-
declare const concatArray: <T, D, C>(...exprs: Expr<Arr<T>, D, C>[]) => Expr<Arr<T>, D, C>;
|
|
567
|
-
declare const first: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
|
|
568
|
-
declare const firstSure: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T, D, C>;
|
|
569
|
-
declare const last: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
|
|
570
|
-
declare const mergeObjects: <T1, T2, D, C = unknown>(exprs_0: Expr<T1, D, C>, exprs_1: Expr<T2, D, C>) => Expr<T1 & T2, D, C>;
|
|
571
|
-
declare const inArray: <T, D, C = unknown>(exprs_0: Expr<T, D, C>, exprs_1: Expr<Arr<T>, D, C>) => Expr<boolean, D, C>;
|
|
572
|
-
declare const slice: <T, D, C>(array: Expr<Arr<T>, D, C>, start: Expr<number, D, C>, end: Expr<number, D, C>) => Expr<Arr<T>, D, C>;
|
|
573
|
-
declare const except: <T, D, C>(a: Expr<Arr<T>, D, C>, b: Expr<Arr<T>, D, C>) => Expr<Arr<T>, D, C>;
|
|
574
|
-
|
|
575
580
|
declare const dayAndMonthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
|
|
576
581
|
declare const now: <D, C>() => Expr<Date, D, C>;
|
|
577
582
|
declare const monthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
|
|
@@ -662,4 +667,4 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
|
|
|
662
667
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
663
668
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
664
669
|
|
|
665
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $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 N, type NoRaw, 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, 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, type notArr, notNull, now, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
670
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $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 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, 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, type notArr, notNull, now, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.esm.js
CHANGED
|
@@ -697,7 +697,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
|
697
697
|
cond: { $ne: ['$$a.before', '$$a.after'] },
|
|
698
698
|
},
|
|
699
699
|
};
|
|
700
|
-
const ifNull = (k, part, str = `$${
|
|
700
|
+
const ifNull = (k, part, str = `$${k}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
|
|
701
701
|
const interDot = ([a, b]) => [a, '.', b];
|
|
702
702
|
const partReplace = (part) => ({
|
|
703
703
|
$cond: {
|
|
@@ -705,7 +705,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
|
705
705
|
then: null,
|
|
706
706
|
else: {
|
|
707
707
|
_id: k
|
|
708
|
-
?
|
|
708
|
+
? ifNull(k, part)
|
|
709
709
|
: {
|
|
710
710
|
$concat: interDot([k1, k2].sort().map(k => ifNull(k, part))),
|
|
711
711
|
},
|
|
@@ -963,7 +963,7 @@ const runCont = async ({ next }, cb) => {
|
|
|
963
963
|
};
|
|
964
964
|
|
|
965
965
|
const merge = ({ lsource: L, rsource: R, }) => mergeIterators({ sources: { L, R } });
|
|
966
|
-
const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup,
|
|
966
|
+
const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup, outerLeft, outerRight) => {
|
|
967
967
|
createIndex(leftSnapshot.coll, { [`before.${lField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
|
|
968
968
|
createIndex(rightSnapshot.coll, { [`before.${rField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
|
|
969
969
|
const rightJoinField = { field1: lField, field2: rField };
|
|
@@ -977,8 +977,8 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
|
|
|
977
977
|
stages: consume => consume(concatTStages(resultingSnapshot, asBefore(stagesUntilNextLookup.raw))),
|
|
978
978
|
out: (finalInput) => {
|
|
979
979
|
const leftJoinField = { field1: rField, field2: lField };
|
|
980
|
-
const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId);
|
|
981
|
-
const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId,
|
|
980
|
+
const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId, outerRight);
|
|
981
|
+
const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId, outerLeft);
|
|
982
982
|
const mergeForeignIntoDoc = concatStages($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({ a: root().of('right').expr(), b: root().of('_id').expr() }, dictId))), stagesUntilNextLookup.delta);
|
|
983
983
|
const lRunnerInput = concatStages(joinR_Delta, mergeForeignIntoDoc);
|
|
984
984
|
const rRunnerInput = concatStages(joinL_Delta, mergeForeignIntoDoc);
|
|
@@ -992,7 +992,7 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
|
|
|
992
992
|
},
|
|
993
993
|
};
|
|
994
994
|
};
|
|
995
|
-
const $lookup1 = (p) => (input) => p.left.stages((lStages) => p.right.stages((rStages) => join(p, lStages, rStages, input)));
|
|
995
|
+
const $lookup1 = (p, outer) => (input) => p.left.stages((lStages) => p.right.stages((rStages) => join(p, lStages, rStages, input, outer?.left, outer?.right)));
|
|
996
996
|
const $lookup = (p) => (l) => $lookup1({
|
|
997
997
|
right: p.from,
|
|
998
998
|
as: p.as,
|
|
@@ -1000,6 +1000,13 @@ const $lookup = (p) => (l) => $lookup1({
|
|
|
1000
1000
|
rField: p.foreignField,
|
|
1001
1001
|
left: l(emptyDelta()),
|
|
1002
1002
|
});
|
|
1003
|
+
const $outerLookup = (p, outer) => (l) => $lookup1({
|
|
1004
|
+
right: p.from,
|
|
1005
|
+
as: p.as,
|
|
1006
|
+
lField: p.localField,
|
|
1007
|
+
rField: p.foreignField,
|
|
1008
|
+
left: l(emptyDelta()),
|
|
1009
|
+
}, outer);
|
|
1003
1010
|
|
|
1004
1011
|
const operator = () => (op) => (operand) => {
|
|
1005
1012
|
return {
|
|
@@ -1771,4 +1778,4 @@ const makeCol = async (docs, database, name) => {
|
|
|
1771
1778
|
}
|
|
1772
1779
|
};
|
|
1773
1780
|
|
|
1774
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $unwind, $unwindDelta, Field, Machine, add, and, 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, notNull, now, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
1781
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $unwind, $unwindDelta, Field, Machine, add, and, 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, notNull, now, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.js
CHANGED
|
@@ -699,7 +699,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
|
699
699
|
cond: { $ne: ['$$a.before', '$$a.after'] },
|
|
700
700
|
},
|
|
701
701
|
};
|
|
702
|
-
const ifNull = (k, part, str = `$${
|
|
702
|
+
const ifNull = (k, part, str = `$${k}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
|
|
703
703
|
const interDot = ([a, b]) => [a, '.', b];
|
|
704
704
|
const partReplace = (part) => ({
|
|
705
705
|
$cond: {
|
|
@@ -707,7 +707,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
|
|
|
707
707
|
then: null,
|
|
708
708
|
else: {
|
|
709
709
|
_id: k
|
|
710
|
-
?
|
|
710
|
+
? ifNull(k, part)
|
|
711
711
|
: {
|
|
712
712
|
$concat: interDot([k1, k2].sort().map(k => ifNull(k, part))),
|
|
713
713
|
},
|
|
@@ -965,7 +965,7 @@ const runCont = async ({ next }, cb) => {
|
|
|
965
965
|
};
|
|
966
966
|
|
|
967
967
|
const merge = ({ lsource: L, rsource: R, }) => mergeIterators({ sources: { L, R } });
|
|
968
|
-
const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup,
|
|
968
|
+
const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup, outerLeft, outerRight) => {
|
|
969
969
|
createIndex(leftSnapshot.coll, { [`before.${lField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
|
|
970
970
|
createIndex(rightSnapshot.coll, { [`before.${rField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
|
|
971
971
|
const rightJoinField = { field1: lField, field2: rField };
|
|
@@ -979,8 +979,8 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
|
|
|
979
979
|
stages: consume => consume(concatTStages(resultingSnapshot, asBefore(stagesUntilNextLookup.raw))),
|
|
980
980
|
out: (finalInput) => {
|
|
981
981
|
const leftJoinField = { field1: rField, field2: lField };
|
|
982
|
-
const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId);
|
|
983
|
-
const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId,
|
|
982
|
+
const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId, outerRight);
|
|
983
|
+
const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId, outerLeft);
|
|
984
984
|
const mergeForeignIntoDoc = concatStages($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({ a: root().of('right').expr(), b: root().of('_id').expr() }, dictId))), stagesUntilNextLookup.delta);
|
|
985
985
|
const lRunnerInput = concatStages(joinR_Delta, mergeForeignIntoDoc);
|
|
986
986
|
const rRunnerInput = concatStages(joinL_Delta, mergeForeignIntoDoc);
|
|
@@ -994,7 +994,7 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
|
|
|
994
994
|
},
|
|
995
995
|
};
|
|
996
996
|
};
|
|
997
|
-
const $lookup1 = (p) => (input) => p.left.stages((lStages) => p.right.stages((rStages) => join(p, lStages, rStages, input)));
|
|
997
|
+
const $lookup1 = (p, outer) => (input) => p.left.stages((lStages) => p.right.stages((rStages) => join(p, lStages, rStages, input, outer?.left, outer?.right)));
|
|
998
998
|
const $lookup = (p) => (l) => $lookup1({
|
|
999
999
|
right: p.from,
|
|
1000
1000
|
as: p.as,
|
|
@@ -1002,6 +1002,13 @@ const $lookup = (p) => (l) => $lookup1({
|
|
|
1002
1002
|
rField: p.foreignField,
|
|
1003
1003
|
left: l(emptyDelta()),
|
|
1004
1004
|
});
|
|
1005
|
+
const $outerLookup = (p, outer) => (l) => $lookup1({
|
|
1006
|
+
right: p.from,
|
|
1007
|
+
as: p.as,
|
|
1008
|
+
lField: p.localField,
|
|
1009
|
+
rField: p.foreignField,
|
|
1010
|
+
left: l(emptyDelta()),
|
|
1011
|
+
}, outer);
|
|
1005
1012
|
|
|
1006
1013
|
const operator = () => (op) => (operand) => {
|
|
1007
1014
|
return {
|
|
@@ -1806,6 +1813,7 @@ exports.$ne = $ne;
|
|
|
1806
1813
|
exports.$nin = $nin;
|
|
1807
1814
|
exports.$nor = $nor;
|
|
1808
1815
|
exports.$or = $or;
|
|
1816
|
+
exports.$outerLookup = $outerLookup;
|
|
1809
1817
|
exports.$pushDict = $pushDict;
|
|
1810
1818
|
exports.$rand = $rand;
|
|
1811
1819
|
exports.$replaceWith = $replaceWith;
|