Skip to main content

Aggregate Class

We had a quick overview over the MongoDB Aggregate Framework, now let's see how we can use it in our application.

Create a new Aggregate

Let's start by creating a new Aggregate instance:

import { Aggregate } from "@warlock.js/cascade";

const aggregate = new Aggregate("users"); // pass the collection name

const usersList = await aggregate.where("id", ">=", 10).get();

Consider using the aggregate class as a query builder, it will help you build your query in a more readable way.