mongodb

Design MongoDB schemas, write queries, and optimize aggregation pipelines and indexes.

Updated Mar 13, 2026
One-click install
npx skills add https://github.com/bacoco/openfang-fork --skill mongodb-bacoco
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongodb
Source: https://github.com/bacoco/openfang-fork/tree/main/crates/openfang-skills/bundled/mongodb
Command: npx skills add https://github.com/bacoco/openfang-fork --skill mongodb-bacoco

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill empowers users to efficiently manage and interact with MongoDB databases, from designing optimal schemas and writing complex queries to ensuring high performance through effective indexing.

Core Features & Use Cases

  • Schema Design: Guidance on embedding vs. referencing, subset/bucket patterns, and versioning.
  • Query Optimization: Best practices for projections, $elemMatch, $in, $text, and avoiding slow operators.
  • Aggregation Framework: Building efficient pipelines with $match, $group, $lookup, $facet, and $merge.
  • Index Management: Strategies for compound indexes, auditing usage, partial/TTL indexes, and dropping unused ones.
  • Pitfall Avoidance: Warnings against unbounded arrays, unindexed queries, wildcard regex, and heavily indexed field updates.

Quick Start

Provide a MongoDB schema design for a blog post with comments, prioritizing read performance for fetching posts and their associated comments.

Frequently Asked Questions about mongodb

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

FAQPage Schema
How do I write efficient MongoDB queries to avoid slow performance?

Optimize MongoDB queries by applying projections, leveraging `$elemMatch` and `$in` operators, and avoiding slow operators or unindexed wildcard regex patterns that cause performance bottlenecks.

What is the best way to structure MongoDB schema design for high read performance?

The best way to structure MongoDB schema design for high read performance is choosing between embedding versus referencing, and utilizing subset or bucket patterns to optimize data retrieval for scalable applications.

How do I build a MongoDB aggregation pipeline with multiple stages?

Construct MongoDB aggregation pipelines by chaining stages like `$match`, `$group`, `$lookup`, `$facet`, and `$merge` to process and transform document data efficiently across multiple operations.

When should I use compound indexes or partial indexes in MongoDB?

Use MongoDB compound indexes for multi-field queries, partial indexes for targeted subsets, and TTL indexes for auto-expiring data, while auditing usage to drop unused indexes and avoid update overhead.

Why do heavily indexed field updates cause performance issues in MongoDB?

Heavily indexed field updates cause MongoDB performance issues because each write operation must modify all associated indexes, creating significant write overhead and slowing database operations.

What are the limitations of using unbounded arrays in MongoDB document models?

Unbounded arrays in MongoDB document models cause document size bloat, memory overhead during retrieval, and degraded write performance, requiring subset or bucket patterns to mitigate these limitations.