UNPKG

mingo

Version:

MongoDB query language for in-memory objects

18 lines (17 loc) 441 B
import { Aggregator } from "../../aggregator"; import { ProcessingMode } from "../../core"; const $facet = (collection, expr, options) => { return collection.transform((array) => { const o = {}; for (const [k, pipeline] of Object.entries(expr)) { o[k] = new Aggregator(pipeline, { ...options, processingMode: ProcessingMode.CLONE_INPUT }).run(array); } return [o]; }); }; export { $facet };