Skip to content

Aggregation Builder

A visual pipeline workspace for MongoDB: add stages, reorder them, edit each step, preview the final payload, then apply it to the editor or run it immediately.

Stage-based pipeline

Each pipeline step stays in its own stage block. That makes the structure easy to reason about instead of editing one long array all at once.

Apply to Editor

Once the pipeline looks right, you can push the assembled payload back into the MQL editor. This is ideal when you want one last review before execution.

Run directly

If there are no validation issues and the connection allows execution, you can run the pipeline directly from the builder without going back through the editor.

The recommended daily workflow

1. Pick the collection first

The builder needs the destination collection so it can parse the current pipeline in the right context and reassemble the final payload consistently.

2. Keep each stage focused

A good stage should do one thing: filter (`$match`), reshape (`$project`), group (`$group`), or sort (`$sort`). This makes debugging far easier.

3. Use the preview to catch issues early

The builder always produces the final serialized payload. If the preview does not match your intent, fixing the stage here is much cheaper than chasing a failed run later.

4. Run only after the issues are clean

Issues such as empty stage bodies or invalid payloads are not cosmetic warnings. They are signals that the pipeline is not reliable enough to run yet.

How the builder helps you avoid mistakes

Empty stages

An empty `$match` or `$group` should not silently slide into the final payload. The builder marks those stages so you can fix the incomplete step.

Safer reordering

Instead of cutting and pasting long JSON, you move stages with explicit controls. That cuts the risk of broken braces, missing commas, or bad stage ordering.

Consistent preview

The preview proves that the current stage list really assembles into a complete payload. It is the bridge between the visual UI and the raw text editor.

What the final payload looks like

Even though you edit stages visually, the builder still produces a normal MQL payload that the rest of the app understands. It is not a separate niche tool; it is simply another authoring mode for the same execution workflow.
Example assembled payload

# The builder collapses multiple stages into one standard aggregate request

{

"action": "aggregate",

"collection": "orders",

"pipeline": [

{ "$match": { "status": "paid" } },

{ "$group": { "_id": "$country", "total": { "$sum": 1 } } },

{ "$sort": { "total": -1 } }

]

}

The Aggregation Builder is excellent for clear, deliberate pipelines, but it is not always the fastest place for extremely custom, long, or expression-heavy cases. When you need total control, apply the result to the editor and continue in raw MQL.

Ready to explore data?

Join the community on GitHub to contribute to the smartest local database IDE.

Launch App