UNPKG

@drip_sync/drip

Version:

Scalable incremental sync for MongoDB aggregation pipelines

30 lines (29 loc) 777 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.synthStage = synthStage; exports.synthPipeline = synthPipeline; function synthStage(s) { if (s.type === "addFields") { return { $addFields: s.fields }; } if (s.type === "match") { return { $match: s.filter }; } if (s.type === "project") { return { $project: s.fields }; } if (s.type === "replaceRoot") { return { $replaceRoot: { newRoot: s.newRoot } }; } if (s.type === "replaceWith") { return { $replaceWith: s.expr }; } if (s.type === "set") { return { $set: s.fields }; } s.type; return { $unset: s.fields }; } function synthPipeline(pipeline) { return pipeline.map(synthStage); }