mongodb-query-patterns

Installation
SKILL.md

MongoDB Query Patterns

Overview

The best query is the one you never make. The second best is the one that fetches only what it needs in a single round-trip.

Before writing any database call, ask: does this data already exist somewhere in the current request chain? If a controller fetched a document and then calls three services, those services should receive the document — not re-fetch it. Pass documents, not IDs.

Think in data flow, not individual queries. Trace how data moves through the request (controller → services → response) and ensure each document makes that journey exactly once.

When to Use

  • Adding any new database operation to a service or controller
  • Building a new endpoint that reads or writes data
  • Wiring service calls together in a controller or orchestration function
  • Adding or modifying Mongoose schemas
  • Reviewing code that chains multiple service calls

Data Flow Principles

Installs
8
GitHub Stars
7
First Seen
Mar 1, 2026
mongodb-query-patterns — 9tykeshav/mern-ninja-cc