
from mern-ninja-cc8
Guidelines and best-practice patterns for writing efficient Mongoose/MongoDB queries and avoiding common performance pitfalls (N+1, unindexed filters, unnecessa
Provides concrete patterns and code examples to write efficient MongoDB/Mongoose queries: hoisting fetches, batching with $in, using .lean(), selective projections, bulkWrite, avoiding .populate() on lists, and indexing filter fields. Helps developers reduce round-trips and eliminate N+1 problems.
Use this skill when adding or reviewing database operations in controllers or services, when building endpoints that read/write MongoDB, or when optimizing existing queries for performance and scalability. Triggers whenever a developer is about to write a new find/findById/aggregate/populate or when code reviews flag repeated queries.
Developer-assistants and code-review agents (Claude Code, Copilot-style review bots, Codex-based assistants).
This skill has not been reviewed by our automated audit pipeline yet.