@valkey/valkey-glide-darwin-arm64 1.2.0 → 1.2.1-rc1
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/build-ts/src/BaseClient.d.ts +27 -1
- package/build-ts/src/BaseClient.js +9 -1
- package/build-ts/src/BaseClient.js.map +1 -1
- package/build-ts/src/Commands.d.ts +12 -0
- package/build-ts/src/Commands.js.map +1 -1
- package/build-ts/src/GlideClient.d.ts +17 -1
- package/build-ts/src/GlideClient.js +3 -0
- package/build-ts/src/GlideClient.js.map +1 -1
- package/build-ts/src/GlideClusterClient.d.ts +23 -7
- package/build-ts/src/GlideClusterClient.js +8 -3
- package/build-ts/src/GlideClusterClient.js.map +1 -1
- package/build-ts/src/ProtobufMessage.js +46 -1
- package/build-ts/src/ProtobufMessage.js.map +1 -1
- package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
- package/node_modules/glide-rs/index.d.ts +2 -1
- package/node_modules/glide-rs/index.js +4 -2
- package/npm/glide/index.ts +4 -3
- package/npm/glide/package.json +0 -1
- package/package.json +2 -2
- package/rust-client/node_modules/mingo/README.md +58 -53
- package/rust-client/node_modules/mingo/dist/cjs/aggregator.js +18 -20
- package/rust-client/node_modules/mingo/dist/cjs/core.js +179 -190
- package/rust-client/node_modules/mingo/dist/cjs/cursor.js +34 -34
- package/rust-client/node_modules/mingo/dist/cjs/index.js +11 -3
- package/rust-client/node_modules/mingo/dist/cjs/init/basic.js +4 -22
- package/rust-client/node_modules/mingo/dist/cjs/init/system.js +6 -6
- package/rust-client/node_modules/mingo/dist/cjs/lazy.js +58 -61
- package/rust-client/node_modules/mingo/dist/cjs/operators/_predicates.js +12 -25
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/_internal.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/accumulator.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/first.js +3 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/last.js +4 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/max.js +9 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/mergeObjects.js +5 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/min.js +9 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/push.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/sum.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/add.js +9 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ceil.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/exp.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/floor.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ln.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log10.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/round.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/sqrt.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/subtract.js +5 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/trunc.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayElemAt.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayToObject.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/concatArrays.js +11 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/filter.js +1 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/first.js +8 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/firstN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/in.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/indexOfArray.js +5 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/isArray.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/last.js +8 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/lastN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/map.js +1 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/maxN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/minN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reduce.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reverseArray.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/sortArray.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/zip.js +4 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/_internal.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/bitNot.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/boolean/not.js +3 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/comparison/cmp.js +6 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/cond.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/ifNull.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/switch.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/_internal.js +157 -65
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateAdd.js +1 -29
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateDiff.js +32 -20
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromParts.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromString.js +13 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateToString.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateTrunc.js +107 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dayOfYear.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/index.js +2 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/isoWeekYear.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/week.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/misc/getField.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/mergeObjects.js +9 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/objectToArray.js +5 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/setField.js +11 -7
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setDifference.js +9 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setEquals.js +17 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIntersection.js +2 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIsSubset.js +15 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setUnion.js +4 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/_internal.js +4 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/concat.js +5 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/indexOfBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceAll.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceOne.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/split.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/strcasecmp.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substr.js +4 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substrBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/atan2.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/cosh.js +0 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/_internal.js +20 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/convert.js +3 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toBool.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDate.js +3 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDouble.js +5 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toInt.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toLong.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toString.js +11 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/type.js +11 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/addFields.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucket.js +53 -53
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucketAuto.js +670 -65
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/count.js +2 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/densify.js +196 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/graphLookup.js +78 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/group.js +6 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/index.js +4 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/limit.js +1 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/lookup.js +47 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/merge.js +7 -13
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/out.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/project.js +19 -38
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/redact.js +3 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/replaceWith.js +9 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sample.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/setWindowFields.js +10 -20
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/skip.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sort.js +10 -19
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sortByCount.js +5 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unionWith.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unwind.js +5 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/projection/elemMatch.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/projection/slice.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/query/bitwise/_internal.js +4 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/_internal.js +8 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/addToSet.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/bit.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/max.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/min.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/pop.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/pull.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/push.js +3 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/rename.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/set.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/_internal.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/denseRank.js +8 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/derivative.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/documentNumber.js +1 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/expMovingAvg.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/integral.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/linearFill.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/locf.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/rank.js +8 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/shift.js +2 -2
- package/rust-client/node_modules/mingo/dist/cjs/query.js +20 -19
- package/rust-client/node_modules/mingo/dist/cjs/types.js +22 -0
- package/rust-client/node_modules/mingo/dist/cjs/updater.js +6 -5
- package/rust-client/node_modules/mingo/dist/cjs/util.js +265 -388
- package/rust-client/node_modules/mingo/dist/esm/aggregator.js +18 -21
- package/rust-client/node_modules/mingo/dist/esm/core.js +179 -192
- package/rust-client/node_modules/mingo/dist/esm/cursor.js +35 -35
- package/rust-client/node_modules/mingo/dist/esm/index.js +8 -2
- package/rust-client/node_modules/mingo/dist/esm/init/basic.js +5 -12
- package/rust-client/node_modules/mingo/dist/esm/init/system.js +7 -7
- package/rust-client/node_modules/mingo/dist/esm/lazy.js +58 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/_predicates.js +14 -32
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/_internal.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/accumulator.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/first.js +7 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/last.js +8 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/max.js +10 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/mergeObjects.js +5 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/min.js +10 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/push.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/sum.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/add.js +9 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ceil.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/exp.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/floor.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ln.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log10.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/round.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/sqrt.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/subtract.js +5 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/trunc.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayElemAt.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayToObject.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/concatArrays.js +12 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/filter.js +2 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/first.js +10 -13
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/firstN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/in.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/indexOfArray.js +5 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/isArray.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/last.js +10 -13
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/lastN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/map.js +2 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/maxN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/minN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reduce.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reverseArray.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/sortArray.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/zip.js +4 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/_internal.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/bitNot.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/boolean/not.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/comparison/cmp.js +6 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/cond.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/ifNull.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/switch.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/_internal.js +140 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateAdd.js +2 -35
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateDiff.js +43 -21
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromParts.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromString.js +13 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateToString.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateTrunc.js +97 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dayOfYear.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/index.js +1 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/isoWeekYear.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/week.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/misc/getField.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/mergeObjects.js +10 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/objectToArray.js +6 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/setField.js +11 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setDifference.js +10 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setEquals.js +18 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIntersection.js +3 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIsSubset.js +16 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setUnion.js +5 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/_internal.js +4 -8
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/concat.js +6 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/indexOfBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceAll.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceOne.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/split.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/strcasecmp.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substr.js +4 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substrBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/atan2.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/cosh.js +0 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/_internal.js +17 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/convert.js +3 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toBool.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDate.js +4 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDouble.js +6 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toInt.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toLong.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toString.js +12 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/type.js +12 -15
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/addFields.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucket.js +54 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucketAuto.js +679 -66
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/count.js +3 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/densify.js +183 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/graphLookup.js +55 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/group.js +6 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/index.js +2 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/limit.js +1 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/lookup.js +55 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/merge.js +9 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/out.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/project.js +21 -42
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/redact.js +3 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/replaceWith.js +9 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sample.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/setWindowFields.js +12 -23
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/skip.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sort.js +11 -20
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sortByCount.js +5 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unionWith.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unwind.js +6 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/projection/elemMatch.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/projection/slice.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/query/bitwise/_internal.js +4 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/update/_internal.js +9 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/update/addToSet.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/bit.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/max.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/min.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/pop.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/pull.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/update/push.js +3 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/update/rename.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/set.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/window/_internal.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/window/denseRank.js +8 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/window/derivative.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/documentNumber.js +1 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/window/expMovingAvg.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/integral.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/window/linearFill.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/locf.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/window/rank.js +8 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/window/shift.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/query.js +22 -32
- package/rust-client/node_modules/mingo/dist/esm/types.js +14 -0
- package/rust-client/node_modules/mingo/dist/esm/updater.js +5 -5
- package/rust-client/node_modules/mingo/dist/esm/util.js +263 -377
- package/rust-client/node_modules/mingo/dist/types/aggregator.d.ts +7 -9
- package/rust-client/node_modules/mingo/dist/types/core.d.ts +41 -52
- package/rust-client/node_modules/mingo/dist/types/cursor.d.ts +6 -12
- package/rust-client/node_modules/mingo/dist/types/index.d.ts +8 -4
- package/rust-client/node_modules/mingo/dist/types/init/basic.d.ts +1 -6
- package/rust-client/node_modules/mingo/dist/types/lazy.d.ts +19 -15
- package/rust-client/node_modules/mingo/dist/types/operators/_predicates.d.ts +20 -20
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/accumulator.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/addToSet.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/avg.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottom.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottomN.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/count.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covariancePop.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covarianceSamp.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/first.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/firstN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/last.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/lastN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/max.d.ts +4 -5
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/maxN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/mergeObjects.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/min.d.ts +4 -5
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/minN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/percentile.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/push.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevPop.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevSamp.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/sum.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/top.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/topN.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/add.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/multiply.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/pow.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/subtract.d.ts +1 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/arrayElemAt.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/concatArrays.d.ts +3 -3
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/filter.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/first.d.ts +0 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/firstN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/in.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/indexOfArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/isArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/last.d.ts +0 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/lastN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/map.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/maxN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/minN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/range.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reduce.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reverseArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/slice.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/_internal.d.ts +31 -9
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateFromString.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateToParts.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateTrunc.d.ts +12 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/index.d.ts +1 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/misc/rand.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/object/mergeObjects.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/percentile.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/set/setIsSubset.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/_internal.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/indexOfBytes.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceAll.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceOne.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/split.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenBytes.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenCP.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/substrBytes.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/type/_internal.d.ts +6 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/_internal.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/addFields.d.ts +8 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucket.d.ts +8 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucketAuto.d.ts +8 -7
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/count.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/densify.d.ts +12 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/facet.d.ts +7 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/fill.d.ts +6 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/graphLookup.d.ts +13 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/group.d.ts +4 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/index.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/limit.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/lookup.d.ts +4 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/match.d.ts +4 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/merge.d.ts +3 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/out.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/project.d.ts +4 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/redact.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceRoot.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceWith.d.ts +8 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sample.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/setWindowFields.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/skip.d.ts +6 -4
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sort.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sortByCount.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unionWith.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unset.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unwind.d.ts +5 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/expr.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/jsonSchema.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/where.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/_internal.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/update/addToSet.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/bit.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/currentDate.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/inc.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/max.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/min.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/mul.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pop.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pull.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pullAll.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/push.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/rename.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/set.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/unset.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/_internal.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/window/denseRank.d.ts +2 -3
- package/rust-client/node_modules/mingo/dist/types/operators/window/derivative.d.ts +2 -3
- package/rust-client/node_modules/mingo/dist/types/operators/window/documentNumber.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/expMovingAvg.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/integral.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/linearFill.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/locf.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/rank.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/shift.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/query.d.ts +5 -7
- package/rust-client/node_modules/mingo/dist/types/types.d.ts +18 -15
- package/rust-client/node_modules/mingo/dist/types/updater.d.ts +9 -10
- package/rust-client/node_modules/mingo/dist/types/util.d.ts +102 -90
- package/rust-client/node_modules/mingo/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Lazy } from "../../lazy";
|
|
2
|
-
import { assert, isString } from "../../util";
|
|
3
|
-
const $count = (collection, expr,
|
|
2
|
+
import { assert, isEmpty, isString } from "../../util";
|
|
3
|
+
const $count = (collection, expr, _options) => {
|
|
4
4
|
assert(
|
|
5
|
-
isString(expr) && expr
|
|
5
|
+
isString(expr) && !isEmpty(expr) && expr.indexOf(".") === -1 && expr.trim()[0] !== "$",
|
|
6
6
|
"Invalid expression value for $count"
|
|
7
7
|
);
|
|
8
8
|
return Lazy([
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { ComputeOptions } from "../../core";
|
|
2
|
+
import { concat, Lazy } from "../../lazy";
|
|
3
|
+
import { TIME_UNITS } from "../../types";
|
|
4
|
+
import {
|
|
5
|
+
assert,
|
|
6
|
+
isArray,
|
|
7
|
+
isDate,
|
|
8
|
+
isNil,
|
|
9
|
+
isNumber,
|
|
10
|
+
isObject,
|
|
11
|
+
isString,
|
|
12
|
+
resolve,
|
|
13
|
+
ValueMap
|
|
14
|
+
} from "../../util";
|
|
15
|
+
import { $dateAdd } from "../expression/date/dateAdd";
|
|
16
|
+
import { $sort } from "./sort";
|
|
17
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
18
|
+
const $densify = (collection, expr, options) => {
|
|
19
|
+
const { step, bounds, unit } = expr.range;
|
|
20
|
+
if (unit) {
|
|
21
|
+
assert(TIME_UNITS.includes(unit), "");
|
|
22
|
+
assert(
|
|
23
|
+
Number.isInteger(step) && step > 0,
|
|
24
|
+
"The step parameter in a range statement must be a whole number when densifying a date range."
|
|
25
|
+
);
|
|
26
|
+
} else {
|
|
27
|
+
assert(
|
|
28
|
+
isNumber(step) && step > 0,
|
|
29
|
+
"The step parameter in a range statement must be a strictly positive numeric value."
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (isArray(bounds)) {
|
|
33
|
+
assert(
|
|
34
|
+
!!bounds && bounds.length === 2,
|
|
35
|
+
"A bounding array in a range statement must have exactly two elements."
|
|
36
|
+
);
|
|
37
|
+
assert(
|
|
38
|
+
(bounds.every(isNumber) || bounds.every(isDate)) && bounds[0] < bounds[1],
|
|
39
|
+
"A bounding array must be an ascending array of either two dates or two numbers."
|
|
40
|
+
);
|
|
41
|
+
assert(
|
|
42
|
+
unit && !bounds.some(isNumber),
|
|
43
|
+
"Numeric bounds may not have unit parameter."
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (expr.partitionByFields) {
|
|
47
|
+
assert(
|
|
48
|
+
isArray(expr.partitionByFields),
|
|
49
|
+
"$densify: `partitionByFields` must be an array of strings"
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
collection = $sort(collection, { [expr.field]: 1 }, options);
|
|
53
|
+
const nilOptions = ComputeOptions.init(options, null);
|
|
54
|
+
const computeNextValue = (value) => {
|
|
55
|
+
return isNumber(value) ? value + step : $dateAdd(
|
|
56
|
+
EMPTY_OBJECT,
|
|
57
|
+
{ startDate: value, unit, amount: step },
|
|
58
|
+
nilOptions
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
const isValidUnit = !!unit && TIME_UNITS.includes(unit);
|
|
62
|
+
const getFieldValue = (o) => {
|
|
63
|
+
const v = resolve(o, expr.field);
|
|
64
|
+
if (isNil(v)) return v;
|
|
65
|
+
if (isNumber(v)) {
|
|
66
|
+
assert(
|
|
67
|
+
!isValidUnit,
|
|
68
|
+
"$densify: Encountered non-date value in collection when step has a date unit."
|
|
69
|
+
);
|
|
70
|
+
} else if (isDate(v)) {
|
|
71
|
+
assert(
|
|
72
|
+
isValidUnit,
|
|
73
|
+
"$densify: Encountered date value in collection when step does not have a date unit."
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
assert(false, "$densify: Densify field type must be numeric or a date");
|
|
77
|
+
}
|
|
78
|
+
return v;
|
|
79
|
+
};
|
|
80
|
+
const peekItem = new Array();
|
|
81
|
+
const nilFieldsIterator = Lazy(() => {
|
|
82
|
+
const item = collection.next();
|
|
83
|
+
const fieldValue = getFieldValue(item.value);
|
|
84
|
+
if (isNil(fieldValue)) return item;
|
|
85
|
+
peekItem.push(item);
|
|
86
|
+
return { done: true };
|
|
87
|
+
});
|
|
88
|
+
const nextDensifyValueMap = ValueMap.init(
|
|
89
|
+
options.hashFunction
|
|
90
|
+
);
|
|
91
|
+
const [lower, upper] = isArray(bounds) ? bounds : [bounds, bounds];
|
|
92
|
+
let maxFieldValue = void 0;
|
|
93
|
+
const updateMaxFieldValue = (value) => {
|
|
94
|
+
maxFieldValue = maxFieldValue === void 0 || maxFieldValue < value ? value : maxFieldValue;
|
|
95
|
+
};
|
|
96
|
+
const rootKey = [];
|
|
97
|
+
const densifyIterator = Lazy(() => {
|
|
98
|
+
const item = peekItem.length > 0 ? peekItem.pop() : collection.next();
|
|
99
|
+
if (item.done) return item;
|
|
100
|
+
let partitionKey = rootKey;
|
|
101
|
+
if (isArray(expr.partitionByFields)) {
|
|
102
|
+
partitionKey = expr.partitionByFields.map(
|
|
103
|
+
(k) => resolve(item.value, k)
|
|
104
|
+
);
|
|
105
|
+
assert(
|
|
106
|
+
partitionKey.every(isString),
|
|
107
|
+
"$densify: Partition fields must evaluate to string values."
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
assert(isObject(item.value), "$densify: collection must contain documents");
|
|
111
|
+
const itemValue = getFieldValue(item.value);
|
|
112
|
+
if (!nextDensifyValueMap.has(partitionKey)) {
|
|
113
|
+
if (lower == "full") {
|
|
114
|
+
if (!nextDensifyValueMap.has(rootKey)) {
|
|
115
|
+
nextDensifyValueMap.set(rootKey, itemValue);
|
|
116
|
+
}
|
|
117
|
+
nextDensifyValueMap.set(partitionKey, nextDensifyValueMap.get(rootKey));
|
|
118
|
+
} else if (lower == "partition") {
|
|
119
|
+
nextDensifyValueMap.set(partitionKey, itemValue);
|
|
120
|
+
} else {
|
|
121
|
+
nextDensifyValueMap.set(partitionKey, lower);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const densifyValue = nextDensifyValueMap.get(partitionKey);
|
|
125
|
+
if (
|
|
126
|
+
// current item field value is lower than current densify value.
|
|
127
|
+
itemValue <= densifyValue || // range value equals or exceeds upper bound
|
|
128
|
+
upper != "full" && upper != "partition" && densifyValue >= upper
|
|
129
|
+
) {
|
|
130
|
+
if (densifyValue <= itemValue) {
|
|
131
|
+
nextDensifyValueMap.set(partitionKey, computeNextValue(densifyValue));
|
|
132
|
+
}
|
|
133
|
+
updateMaxFieldValue(itemValue);
|
|
134
|
+
return item;
|
|
135
|
+
}
|
|
136
|
+
nextDensifyValueMap.set(partitionKey, computeNextValue(densifyValue));
|
|
137
|
+
updateMaxFieldValue(densifyValue);
|
|
138
|
+
const denseObj = { [expr.field]: densifyValue };
|
|
139
|
+
if (partitionKey) {
|
|
140
|
+
partitionKey.forEach((v, i) => {
|
|
141
|
+
denseObj[expr.partitionByFields[i]] = v;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
peekItem.push(item);
|
|
145
|
+
return { done: false, value: denseObj };
|
|
146
|
+
});
|
|
147
|
+
if (lower !== "full") return concat(nilFieldsIterator, densifyIterator);
|
|
148
|
+
let paritionIndex = -1;
|
|
149
|
+
let partitionKeysSet = void 0;
|
|
150
|
+
const fullBoundsIterator = Lazy(() => {
|
|
151
|
+
if (paritionIndex === -1) {
|
|
152
|
+
const fullDensifyValue = nextDensifyValueMap.get(rootKey);
|
|
153
|
+
nextDensifyValueMap.delete(rootKey);
|
|
154
|
+
partitionKeysSet = Array.from(nextDensifyValueMap.keys());
|
|
155
|
+
if (partitionKeysSet.length === 0) {
|
|
156
|
+
partitionKeysSet.push(rootKey);
|
|
157
|
+
nextDensifyValueMap.set(rootKey, fullDensifyValue);
|
|
158
|
+
}
|
|
159
|
+
paritionIndex++;
|
|
160
|
+
}
|
|
161
|
+
do {
|
|
162
|
+
const partitionKey = partitionKeysSet[paritionIndex];
|
|
163
|
+
const partitionMaxValue = nextDensifyValueMap.get(partitionKey);
|
|
164
|
+
if (partitionMaxValue < maxFieldValue) {
|
|
165
|
+
nextDensifyValueMap.set(
|
|
166
|
+
partitionKey,
|
|
167
|
+
computeNextValue(partitionMaxValue)
|
|
168
|
+
);
|
|
169
|
+
const denseObj = { [expr.field]: partitionMaxValue };
|
|
170
|
+
partitionKey.forEach((v, i) => {
|
|
171
|
+
denseObj[expr.partitionByFields[i]] = v;
|
|
172
|
+
});
|
|
173
|
+
return { done: false, value: denseObj };
|
|
174
|
+
}
|
|
175
|
+
paritionIndex++;
|
|
176
|
+
} while (paritionIndex < partitionKeysSet.length);
|
|
177
|
+
return { done: true };
|
|
178
|
+
});
|
|
179
|
+
return concat(nilFieldsIterator, densifyIterator, fullBoundsIterator);
|
|
180
|
+
};
|
|
181
|
+
export {
|
|
182
|
+
$densify
|
|
183
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { computeValue } from "../../core";
|
|
2
|
+
import { Lazy } from "../../lazy";
|
|
3
|
+
import { flatten, isNil, isString, setValue, ValueMap } from "../../util";
|
|
4
|
+
import { $lookup } from "./lookup";
|
|
5
|
+
const $graphLookup = (collection, expr, options) => {
|
|
6
|
+
const fromColl = isString(expr.from) ? options?.collectionResolver(expr.from) : expr.from;
|
|
7
|
+
const {
|
|
8
|
+
connectFromField,
|
|
9
|
+
connectToField,
|
|
10
|
+
as: asField,
|
|
11
|
+
maxDepth,
|
|
12
|
+
depthField,
|
|
13
|
+
restrictSearchWithMatch: matchExpr
|
|
14
|
+
} = expr;
|
|
15
|
+
const pipelineExpr = matchExpr ? { pipeline: [{ $match: matchExpr }] } : {};
|
|
16
|
+
return collection.map((obj) => {
|
|
17
|
+
const matchObj = {};
|
|
18
|
+
setValue(
|
|
19
|
+
matchObj,
|
|
20
|
+
connectFromField,
|
|
21
|
+
computeValue(obj, expr.startWith, null, options)
|
|
22
|
+
);
|
|
23
|
+
let matches = [matchObj];
|
|
24
|
+
let i = -1;
|
|
25
|
+
const map = ValueMap.init(options.hashFunction);
|
|
26
|
+
do {
|
|
27
|
+
i++;
|
|
28
|
+
matches = flatten(
|
|
29
|
+
$lookup(
|
|
30
|
+
Lazy(matches),
|
|
31
|
+
{
|
|
32
|
+
from: fromColl,
|
|
33
|
+
localField: connectFromField,
|
|
34
|
+
foreignField: connectToField,
|
|
35
|
+
as: asField,
|
|
36
|
+
...pipelineExpr
|
|
37
|
+
},
|
|
38
|
+
options
|
|
39
|
+
).map((o) => o[asField]).value()
|
|
40
|
+
);
|
|
41
|
+
const oldSize = map.size;
|
|
42
|
+
matches.forEach((k) => map.set(k, map.get(k) ?? i));
|
|
43
|
+
if (oldSize == map.size) break;
|
|
44
|
+
} while (isNil(maxDepth) || i < maxDepth);
|
|
45
|
+
const result = new Array(map.size);
|
|
46
|
+
let n = 0;
|
|
47
|
+
map.forEach((v, k) => {
|
|
48
|
+
result[n++] = Object.assign(depthField ? { [depthField]: v } : {}, k);
|
|
49
|
+
});
|
|
50
|
+
return { ...obj, [asField]: result };
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
$graphLookup
|
|
55
|
+
};
|
|
@@ -5,33 +5,30 @@ import {
|
|
|
5
5
|
import { assert, groupBy, has } from "../../util";
|
|
6
6
|
const ID_KEY = "_id";
|
|
7
7
|
const $group = (collection, expr, options) => {
|
|
8
|
-
assert(has(expr, ID_KEY), "
|
|
8
|
+
assert(has(expr, ID_KEY), "$group specification must include an '_id'");
|
|
9
9
|
const idExpr = expr[ID_KEY];
|
|
10
10
|
const copts = ComputeOptions.init(options);
|
|
11
|
+
const newFields = Object.keys(expr).filter((k) => k != ID_KEY);
|
|
11
12
|
return collection.transform((coll) => {
|
|
12
13
|
const partitions = groupBy(
|
|
13
14
|
coll,
|
|
14
15
|
(obj) => computeValue(obj, idExpr, null, options),
|
|
15
16
|
options.hashFunction
|
|
16
17
|
);
|
|
17
|
-
expr = { ...expr };
|
|
18
|
-
delete expr[ID_KEY];
|
|
19
18
|
let i = -1;
|
|
20
19
|
const partitionKeys = Array.from(partitions.keys());
|
|
21
|
-
const size = partitions.size;
|
|
22
20
|
return () => {
|
|
23
|
-
if (++i === size)
|
|
24
|
-
return { done: true };
|
|
21
|
+
if (++i === partitions.size) return { done: true };
|
|
25
22
|
const groupId = partitionKeys[i];
|
|
26
23
|
const obj = {};
|
|
27
24
|
if (groupId !== void 0) {
|
|
28
25
|
obj[ID_KEY] = groupId;
|
|
29
26
|
}
|
|
30
|
-
for (const
|
|
27
|
+
for (const key of newFields) {
|
|
31
28
|
obj[key] = computeValue(
|
|
32
29
|
partitions.get(groupId),
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
expr[key],
|
|
31
|
+
null,
|
|
35
32
|
copts.update(null, { groupId })
|
|
36
33
|
);
|
|
37
34
|
}
|
|
@@ -2,8 +2,10 @@ export * from "./addFields";
|
|
|
2
2
|
export * from "./bucket";
|
|
3
3
|
export * from "./bucketAuto";
|
|
4
4
|
export * from "./count";
|
|
5
|
+
export * from "./densify";
|
|
5
6
|
export * from "./facet";
|
|
6
7
|
export * from "./fill";
|
|
8
|
+
export * from "./graphLookup";
|
|
7
9
|
export * from "./group";
|
|
8
10
|
export * from "./limit";
|
|
9
11
|
export * from "./lookup";
|
|
@@ -1,18 +1,62 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Aggregator } from "../../aggregator";
|
|
2
|
+
import { computeValue } from "../../core";
|
|
3
|
+
import {
|
|
4
|
+
ensureArray,
|
|
5
|
+
flatten,
|
|
6
|
+
isArray,
|
|
7
|
+
isString,
|
|
8
|
+
resolve,
|
|
9
|
+
ValueMap
|
|
10
|
+
} from "../../util";
|
|
2
11
|
const $lookup = (collection, expr, options) => {
|
|
3
12
|
const joinColl = isString(expr.from) ? options?.collectionResolver(expr.from) : expr.from;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
const { let: letExpr, pipeline, foreignField, localField } = expr;
|
|
14
|
+
const subQueryPipeline = pipeline || [];
|
|
15
|
+
let lookupEq = (_) => [true, []];
|
|
16
|
+
if (foreignField && localField) {
|
|
17
|
+
const map = ValueMap.init(options.hashFunction);
|
|
18
|
+
for (const doc of joinColl) {
|
|
19
|
+
ensureArray(resolve(doc, foreignField) ?? null).forEach((v) => {
|
|
20
|
+
const xs = map.get(v);
|
|
21
|
+
const arr = xs ?? [];
|
|
22
|
+
arr.push(doc);
|
|
23
|
+
if (arr !== xs) map.set(v, arr);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
lookupEq = (o) => {
|
|
27
|
+
const local = resolve(o, localField) ?? null;
|
|
28
|
+
if (isArray(local)) {
|
|
29
|
+
if (subQueryPipeline.length) {
|
|
30
|
+
return [local.some((v) => map.has(v)), null];
|
|
31
|
+
}
|
|
32
|
+
const result2 = Array.from(
|
|
33
|
+
new Set(flatten(local.map((v) => map.get(v), options.hashFunction)))
|
|
34
|
+
);
|
|
35
|
+
return [result2.length > 0, result2];
|
|
36
|
+
}
|
|
37
|
+
const result = map.get(local) ?? null;
|
|
38
|
+
return [result !== null, result ?? []];
|
|
39
|
+
};
|
|
40
|
+
if (subQueryPipeline.length === 0) {
|
|
41
|
+
return collection.map((obj) => {
|
|
42
|
+
return {
|
|
43
|
+
...obj,
|
|
44
|
+
[expr.as]: lookupEq(obj).pop()
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
10
48
|
}
|
|
49
|
+
const agg = new Aggregator(subQueryPipeline, options);
|
|
11
50
|
return collection.map((obj) => {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
51
|
+
const variables = computeValue(obj, letExpr, null, options);
|
|
52
|
+
const opts = Object.assign({}, options, {
|
|
53
|
+
variables: { ...options.variables, ...variables }
|
|
54
|
+
});
|
|
55
|
+
const [ok, res] = lookupEq(obj);
|
|
56
|
+
return {
|
|
57
|
+
...obj,
|
|
58
|
+
[expr.as]: ok ? agg.run(joinColl, opts) : res
|
|
59
|
+
};
|
|
16
60
|
});
|
|
17
61
|
};
|
|
18
62
|
export {
|
|
@@ -9,35 +9,30 @@ import {
|
|
|
9
9
|
isArray,
|
|
10
10
|
isString,
|
|
11
11
|
MingoError,
|
|
12
|
-
resolve
|
|
12
|
+
resolve,
|
|
13
|
+
ValueMap
|
|
13
14
|
} from "../../util";
|
|
14
15
|
import { $mergeObjects } from "../expression";
|
|
15
16
|
const $merge = (collection, expr, options) => {
|
|
16
17
|
const output = isString(expr.into) ? options?.collectionResolver(expr.into) : expr.into;
|
|
17
|
-
assert(
|
|
18
|
-
output instanceof Array,
|
|
19
|
-
`$merge: option 'into' must resolve to an array`
|
|
20
|
-
);
|
|
18
|
+
assert(isArray(output), `$merge: option 'into' must resolve to an array`);
|
|
21
19
|
const onField = expr.on || options.idKey;
|
|
22
|
-
const getHash = (o) =>
|
|
23
|
-
|
|
24
|
-
return hashCode(val, options.hashFunction);
|
|
25
|
-
};
|
|
26
|
-
const hash = {};
|
|
20
|
+
const getHash = isString(onField) ? (o) => hashCode(resolve(o, onField), options.hashFunction) : (o) => hashCode(onField.map((s) => resolve(o, s), options.hashFunction));
|
|
21
|
+
const map = ValueMap.init();
|
|
27
22
|
for (let i = 0; i < output.length; i++) {
|
|
28
23
|
const obj = output[i];
|
|
29
24
|
const k = getHash(obj);
|
|
30
25
|
assert(
|
|
31
|
-
!
|
|
26
|
+
!map.has(k),
|
|
32
27
|
"$merge: 'into' collection must have unique entries for the 'on' field."
|
|
33
28
|
);
|
|
34
|
-
|
|
29
|
+
map.set(k, [obj, i]);
|
|
35
30
|
}
|
|
36
31
|
const copts = ComputeOptions.init(options);
|
|
37
32
|
return collection.map((o) => {
|
|
38
33
|
const k = getHash(o);
|
|
39
|
-
if (
|
|
40
|
-
const [target, i] =
|
|
34
|
+
if (map.has(k)) {
|
|
35
|
+
const [target, i] = map.get(k);
|
|
41
36
|
const variables = computeValue(
|
|
42
37
|
target,
|
|
43
38
|
expr.let || { new: "$$ROOT" },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { assert, cloneDeep, isString } from "../../util";
|
|
1
|
+
import { assert, cloneDeep, isArray, isString } from "../../util";
|
|
2
2
|
const $out = (collection, expr, options) => {
|
|
3
3
|
const outputColl = isString(expr) ? options?.collectionResolver(expr) : expr;
|
|
4
|
-
assert(outputColl
|
|
4
|
+
assert(isArray(outputColl), `expression must resolve to an array`);
|
|
5
5
|
return collection.map((o) => {
|
|
6
6
|
outputColl.push(cloneDeep(o));
|
|
7
7
|
return o;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComputeOptions,
|
|
3
3
|
computeValue,
|
|
4
|
-
getOperator
|
|
5
|
-
OperatorType
|
|
4
|
+
getOperator
|
|
6
5
|
} from "../../core";
|
|
7
6
|
import {
|
|
8
7
|
assert,
|
|
9
8
|
ensureArray,
|
|
10
9
|
filterMissing,
|
|
11
10
|
has,
|
|
12
|
-
inArray,
|
|
13
11
|
into,
|
|
12
|
+
isArray,
|
|
14
13
|
isEmpty,
|
|
15
14
|
isNil,
|
|
16
15
|
isNumber,
|
|
@@ -18,42 +17,27 @@ import {
|
|
|
18
17
|
isOperator,
|
|
19
18
|
isString,
|
|
20
19
|
merge,
|
|
21
|
-
notInArray,
|
|
22
20
|
removeValue,
|
|
23
21
|
resolveGraph,
|
|
24
22
|
setValue
|
|
25
23
|
} from "../../util";
|
|
24
|
+
const DESCRIPTORS = new Set(Array.from([0, 1, false, true]));
|
|
26
25
|
const $project = (collection, expr, options) => {
|
|
27
|
-
if (isEmpty(expr))
|
|
28
|
-
|
|
29
|
-
let expressionKeys = Object.keys(expr);
|
|
30
|
-
let idOnlyExcluded = false;
|
|
26
|
+
if (isEmpty(expr)) return collection;
|
|
27
|
+
const expressionKeys = Object.keys(expr);
|
|
31
28
|
validateExpression(expr, options);
|
|
32
29
|
const ID_KEY = options.idKey;
|
|
33
|
-
if (
|
|
34
|
-
const id = expr[ID_KEY];
|
|
35
|
-
if (id === 0 || id === false) {
|
|
36
|
-
expressionKeys = expressionKeys.filter(
|
|
37
|
-
notInArray.bind(null, [ID_KEY])
|
|
38
|
-
);
|
|
39
|
-
idOnlyExcluded = expressionKeys.length == 0;
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
30
|
+
if (!expressionKeys.includes(ID_KEY)) {
|
|
42
31
|
expressionKeys.push(ID_KEY);
|
|
43
32
|
}
|
|
44
33
|
const copts = ComputeOptions.init(options);
|
|
45
|
-
return collection.map((obj) => processObject(
|
|
46
|
-
obj,
|
|
47
|
-
expr,
|
|
48
|
-
copts.update(obj),
|
|
49
|
-
expressionKeys,
|
|
50
|
-
idOnlyExcluded
|
|
51
|
-
));
|
|
34
|
+
return collection.map((obj) => processObject(obj, expr, copts.update(obj), expressionKeys));
|
|
52
35
|
};
|
|
53
|
-
function processObject(obj, expr, options, expressionKeys
|
|
36
|
+
function processObject(obj, expr, options, expressionKeys) {
|
|
54
37
|
let newObj = {};
|
|
55
38
|
let foundSlice = false;
|
|
56
39
|
let foundExclusion = false;
|
|
40
|
+
const idOnlyExcluded = expr[options.idKey] === 0 && expressionKeys.length === 1;
|
|
57
41
|
const dropKeys = [];
|
|
58
42
|
if (idOnlyExcluded) {
|
|
59
43
|
dropKeys.push(options.idKey);
|
|
@@ -61,19 +45,18 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
|
|
|
61
45
|
for (const key of expressionKeys) {
|
|
62
46
|
let value = void 0;
|
|
63
47
|
const subExpr = expr[key];
|
|
64
|
-
if (key !== options.idKey &&
|
|
48
|
+
if (key !== options.idKey && (subExpr === 0 || subExpr === false)) {
|
|
65
49
|
foundExclusion = true;
|
|
66
50
|
}
|
|
67
51
|
if (key === options.idKey && isEmpty(subExpr)) {
|
|
68
52
|
value = obj[key];
|
|
69
53
|
} else if (isString(subExpr)) {
|
|
70
54
|
value = computeValue(obj, subExpr, key, options);
|
|
71
|
-
} else if (
|
|
72
|
-
} else if (subExpr
|
|
55
|
+
} else if (subExpr === 1 || subExpr === true) {
|
|
56
|
+
} else if (isArray(subExpr)) {
|
|
73
57
|
value = subExpr.map((v) => {
|
|
74
58
|
const r = computeValue(obj, v, null, options);
|
|
75
|
-
if (isNil(r))
|
|
76
|
-
return null;
|
|
59
|
+
if (isNil(r)) return null;
|
|
77
60
|
return r;
|
|
78
61
|
});
|
|
79
62
|
} else if (isObject(subExpr)) {
|
|
@@ -81,7 +64,7 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
|
|
|
81
64
|
const subExprKeys = Object.keys(subExpr);
|
|
82
65
|
const operator = subExprKeys.length == 1 ? subExprKeys[0] : "";
|
|
83
66
|
const call = getOperator(
|
|
84
|
-
|
|
67
|
+
"projection",
|
|
85
68
|
operator,
|
|
86
69
|
options
|
|
87
70
|
);
|
|
@@ -101,9 +84,9 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
|
|
|
101
84
|
} else if (has(obj, key)) {
|
|
102
85
|
validateExpression(subExprObj, options);
|
|
103
86
|
let target = obj[key];
|
|
104
|
-
if (target
|
|
87
|
+
if (isArray(target)) {
|
|
105
88
|
value = target.map(
|
|
106
|
-
(o) => processObject(o, subExprObj, options, subExprKeys
|
|
89
|
+
(o) => processObject(o, subExprObj, options, subExprKeys)
|
|
107
90
|
);
|
|
108
91
|
} else {
|
|
109
92
|
target = isObject(target) ? target : obj;
|
|
@@ -111,8 +94,7 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
|
|
|
111
94
|
target,
|
|
112
95
|
subExprObj,
|
|
113
96
|
options,
|
|
114
|
-
subExprKeys
|
|
115
|
-
false
|
|
97
|
+
subExprKeys
|
|
116
98
|
);
|
|
117
99
|
}
|
|
118
100
|
} else {
|
|
@@ -125,12 +107,10 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
|
|
|
125
107
|
const objPathGraph = resolveGraph(obj, key, {
|
|
126
108
|
preserveMissing: true
|
|
127
109
|
});
|
|
128
|
-
if (objPathGraph
|
|
129
|
-
merge(newObj, objPathGraph
|
|
130
|
-
flatten: true
|
|
131
|
-
});
|
|
110
|
+
if (isObject(objPathGraph)) {
|
|
111
|
+
merge(newObj, objPathGraph);
|
|
132
112
|
}
|
|
133
|
-
if (
|
|
113
|
+
if (!DESCRIPTORS.has(subExpr)) {
|
|
134
114
|
if (value === void 0) {
|
|
135
115
|
removeValue(newObj, key, { descendArray: true });
|
|
136
116
|
} else {
|
|
@@ -152,8 +132,7 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
|
|
|
152
132
|
function validateExpression(expr, options) {
|
|
153
133
|
const check = [false, false];
|
|
154
134
|
for (const [k, v] of Object.entries(expr)) {
|
|
155
|
-
if (k === options?.idKey)
|
|
156
|
-
return;
|
|
135
|
+
if (k === options?.idKey) return;
|
|
157
136
|
if (v === 0 || v === false) {
|
|
158
137
|
check[0] = true;
|
|
159
138
|
} else if (v === 1 || v === true) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ComputeOptions, redact } from "../../core";
|
|
2
2
|
const $redact = (collection, expr, options) => {
|
|
3
3
|
const copts = ComputeOptions.init(options);
|
|
4
|
-
return collection.map(
|
|
4
|
+
return collection.map(
|
|
5
|
+
(obj) => redact(obj, expr, copts.update(obj))
|
|
6
|
+
);
|
|
5
7
|
};
|
|
6
8
|
export {
|
|
7
9
|
$redact
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { computeValue } from "../../core";
|
|
2
|
+
import { assert, isObject } from "../../util";
|
|
3
|
+
const $replaceWith = (collection, expr, options) => {
|
|
4
|
+
return collection.map((obj) => {
|
|
5
|
+
obj = computeValue(obj, expr, null, options);
|
|
6
|
+
assert(isObject(obj), "$replaceWith expression must return an object");
|
|
7
|
+
return obj;
|
|
8
|
+
});
|
|
9
|
+
};
|
|
3
10
|
export {
|
|
4
11
|
$replaceWith
|
|
5
12
|
};
|
|
@@ -3,8 +3,7 @@ const $sample = (collection, expr, _options) => {
|
|
|
3
3
|
const len = xs.length;
|
|
4
4
|
let i = -1;
|
|
5
5
|
return () => {
|
|
6
|
-
if (++i === expr.size)
|
|
7
|
-
return { done: true };
|
|
6
|
+
if (++i === expr.size) return { done: true };
|
|
8
7
|
const n = Math.floor(Math.random() * len);
|
|
9
8
|
return { value: xs[n], done: false };
|
|
10
9
|
};
|