Create an aggregate
Write and test a MongoDB aggregation pipeline.
Where: Database → Aggregates → New · /projects/<project>/db/aggregates/new
Fields
Schema (required) — the collection the pipeline runs on. Picking one shows a Sample record panel with the first record from that collection, so you can see the field names you are aggregating.
Name (required) and Description.
The pipeline editor — standard MongoDB stages as JSON. Strict JSON validation is off on purpose: you may embed tokens that start with
@Model, e.g.{ "$match": { "birthDate": { "$gt": @Model.userBirthday } } }, and pass the values at execution time.TEST — runs the pipeline against live data and shows the response as an expandable JSON tree. When the pipeline contains
@Modeltokens, a modal first asks for a test value per token.
Example pipeline — paid orders per customer, biggest spenders first:
[
{ "$match": { "status": "paid" } },
{ "$group": { "_id": "$customerId", "orders": { "$sum": 1 }, "total": { "$sum": "$amount" } } },
{ "$sort": { "total": -1 } }
]Save stores the aggregate and returns to the list; it gets an id (maggr_…) your app calls with executeAggregate. Create using AI Chat opens the assistant, which reads your schema fields, drafts the pipeline into this editor, and leaves saving to you.
Use it from code
API reference
Endpoints: Save Database Aggregate, Test Database Aggregate, Execute Aggregate.
Last updated