From e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d Mon Sep 17 00:00:00 2001 From: Piotr Russ Date: Mon, 16 Nov 2020 00:10:28 +0100 Subject: api, login, auth --- .../aggregate/stringifyAccumulatorOptions.js | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 node_modules/mongoose/lib/helpers/aggregate/stringifyAccumulatorOptions.js (limited to 'node_modules/mongoose/lib/helpers/aggregate') diff --git a/node_modules/mongoose/lib/helpers/aggregate/stringifyAccumulatorOptions.js b/node_modules/mongoose/lib/helpers/aggregate/stringifyAccumulatorOptions.js new file mode 100644 index 0000000..7362514 --- /dev/null +++ b/node_modules/mongoose/lib/helpers/aggregate/stringifyAccumulatorOptions.js @@ -0,0 +1,38 @@ +'use strict'; + +module.exports = function stringifyAccumulatorOptions(pipeline) { + if (!Array.isArray(pipeline)) { + return; + } + + for (const stage of pipeline) { + if (stage == null) { + continue; + } + + const canHaveAccumulator = stage.$group || stage.$bucket || stage.$bucketAuto; + if (canHaveAccumulator != null) { + for (const key of Object.keys(canHaveAccumulator)) { + handleAccumulator(canHaveAccumulator[key]); + } + } + + if (stage.$facet != null) { + for (const key of Object.keys(stage.$facet)) { + stringifyAccumulatorOptions(stage.$facet[key]); + } + } + } +}; + +function handleAccumulator(operator) { + if (operator == null || operator.$accumulator == null) { + return; + } + + for (const key of ['init', 'accumulate', 'merge', 'finalize']) { + if (typeof operator.$accumulator[key] === 'function') { + operator.$accumulator[key] = String(operator.$accumulator[key]); + } + } +} \ No newline at end of file -- cgit v1.2.3