mongodb

SKILL.md

MongoDB Best Practices

Schema Design

  • Embed data for 1:few relationships
  • Reference data for 1:many relationships
  • Avoid unbounded arrays
  • Use meaningful field names
  • Plan for your query patterns

Indexing

  • Index fields used in queries
  • Use compound indexes wisely
  • Monitor index size
  • Use TTL indexes for expiring data
  • Text indexes for search

Queries

  • Use projection to limit fields
  • Use aggregation pipeline for complex queries
  • Avoid $where and $regex when possible
  • Use explain() to analyze queries
  • Paginate with skip/limit or cursor

Performance

  • Use connection pooling
  • Shard for horizontal scaling
  • Use read preferences
  • Enable compression
  • Monitor with mongotop/mongostat

Security

  • Enable authentication
  • Use role-based access control
  • Encrypt data at rest
  • Use TLS for connections
  • Validate input data
Weekly Installs
2
First Seen
Feb 28, 2026
Installed on
opencode2
gemini-cli2
codebuddy2
github-copilot2
codex2
kimi-cli2