aggregation

Run MongoDB aggregation pipelines to transform and group documents.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/theslashdojo/dojo --skill aggregation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aggregation
Source: https://github.com/theslashdojo/dojo/tree/main/nodes/mongodb/aggregation
Command: npx skills add https://github.com/theslashdojo/dojo --skill aggregation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires mongodb, bson, and includes scripts (resource) components.

What problem does it solve?

When plain find queries cannot express grouping, joins, reshaping, or multi-stage transformations, this Skill runs MongoDB aggregation pipelines to produce reporting, enrichment, and materialized outputs without manual pipeline orchestration.

Core Features & Use Cases

  • Execute multi-stage aggregation pipelines against a target database and collection with configurable options such as allowDiskUse and explain.
  • Support for reading Extended JSON input from an environment variable or stdin and returning either result documents or an explain plan.
  • Practical guidance on pipeline design: push $match early, keep $project tight, use explain for slow pipelines, and treat $merge/$out as destructive writes.
  • Use cases include analytics reports, denormalized views, exports, enrichment jobs, and ad-hoc investigative queries.

Quick Start

Provide a JSON payload or set AGGREGATION_INPUT_JSON with database, collection, and pipeline and run the included node script to execute the aggregation and receive results or an explain plan.

Frequently Asked Questions about aggregation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a MongoDB aggregation pipeline for grouping and reshaping documents?

Use the explain option to return an execution plan instead of result documents. Running an explain plan helps identify slow stages in the MongoDB aggregation pipeline, guiding optimizations like pushing $match early and keeping $project tight.

When should I use allowDiskUse for a MongoDB aggregation pipeline?

Use the allowDiskUse option when your MongoDB aggregation pipeline encounters memory limits during heavy sorting or grouping operations. It permits the pipeline to write temporary data to disk, preventing failures on large datasets.

Can I execute a MongoDB aggregation pipeline using Extended JSON input?

Yes, MongoDB aggregation pipelines support $merge and $out stages to write transformed documents to target collections. Treat these stages as destructive writes, as they materialize outputs directly into the specified database collections.

Do I need the mongodb and bson Node.js drivers to run aggregation pipelines?

Yes, you need the mongodb and bson Node.js drivers installed as dependencies. The Skill executes aggregation pipelines through a Node.js script that relies on these drivers to connect to the database and process Extended JSON input.