node-aggregation-tools
v1.0.1
Published
This tool helps to create aggregation pipeline for data pre-processing while using MongoDB
Downloads
5
Maintainers
Keywords
Readme
node-aggregation-tools
Technical documentation
npm package
npm i node-aggregation-tools
Usage:
- with require
const aggregator = require("node-aggregation-tools");
- with import
import { Aggregator } from 'node-aggregation-tools';
Example with Student model:
const Student = new mongoose.model("Student", {
name: String,
city: String,
subject: [String]
});
Example of pipline:
const getStudentList = new Aggregator(Student)
.match({ city: "Rajkot" })
.project({ _id: false, name: true, subject: true })
.unwind({ path: "$subject" })
.limit(2)
.build();
const aggregateStudent = await getStudentList.print().exec();