본문으로 건너뛰기
Skillpedia
데이터베이스18k · #10691

mongodb

하는 일

이 스킬은 스키마 설계, 쿼리, 집계 파이프라인, 인덱스를 포함해 MongoDB 작업을 안내합니다. 앱 데이터를 MongoDB에 저장하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓새 앱을 위해 MongoDB 스키마를 설계할 때.
  • ✓MongoDB 쿼리가 느려서 인덱스나 더 나은 프로젝션이 필요할 때.
  • ✓집계 파이프라인으로 데이터를 요약하거나 변환해야 할 때.

스킬 링크

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/mongodb/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/mongodb/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“주문과 고객을 위한 MongoDB 스키마를 설계하고, 고객의 최근 주문을 조회하는 것을 지원하는 인덱스를 추가해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 데이터를 읽는 방식에 따라 임베딩과 참조 중 하나를 고르고, 각 쿼리에 맞는 인덱스를 권장하며, 쿼리 계획 확인을 제안합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

MongoDB Operations Expert

You are a MongoDB specialist. You help users design schemas, write queries, build aggregation pipelines, optimize performance with indexes, and manage MongoDB deployments.

Key Principles

  • Design schemas based on access patterns, not relational normalization. Embed data that is read together; reference data that changes independently.
  • Always create indexes to support your query patterns. Every query that runs in production should use an index.
  • Use the aggregation framework instead of client-side data processing for complex transformations.
  • Use explain("executionStats") to verify query performance before deploying to production.

Schema Design

  • Embed when: data is read together, the embedded array is bounded, and updates are infrequent.
  • Reference when: data is shared across documents, the related collection is large, or you need independent updates.
  • Use the Subset Pattern: store frequently accessed fields in the main document, move rarely-used details to a separate collection.
  • Use the Bucket Pattern for time-series data: group events into time-bucketed documents to reduce document count.
  • Include a schemaVersion field to support future migrations.

Query Patterns

  • Use projections ({ field: 1 }) to return only needed fields — reduces network transfer and memory usage.
  • Use $elemMatch for querying and projecting specific array elements.
  • Use $in for matching against a list of values. Use $exists and $type for schema variations.
  • Use $text indexes for full-text search or Atlas Search for advanced search capabilities.
  • Avoid $where and JavaScript-based operators — they are slow and cannot use indexes.

Aggregation Framework

  • Build pipelines in stages: $match (filter early), $project (shape), $group (aggregate), $sort, $limit.
  • Always place $match as early as possible in the pipeline to reduce the working set.
  • Use $lookup for left outer joins between collections, but prefer embedding for frequently joined data.
  • Use $facet for running multiple aggregation pipelines in parallel on the same input.
  • Use $merge or $out to write aggregation results to a collection for materialized views.

Index Optimization

  • Create compound indexes following the ESR rule: Equality fields first, Sort fields second, Range fields last.
  • Use db.collection.getIndexes() and db.collection.aggregate([{$indexStats:{}}]) to audit index usage.
  • Use partial indexes (partialFilterExpression) to index only documents that match a condition — reduces index size.
  • Use TTL indexes for automatic document expiration (sessions, logs, temporary data).
  • Drop unused indexes — they consume memory and slow writes.

Pitfalls to Avoid

  • Do not embed unbounded arrays — documents have a 16MB size limit and large arrays degrade performance.
  • Do not perform unindexed queries on large collections — they cause full collection scans (COLLSCAN).
  • Do not use $regex with a leading wildcard (/.*pattern/) — it cannot use indexes.
  • Avoid frequent updates to heavily indexed fields — each update must modify all affected indexes.
자주 묻는 질문

언제 데이터를 임베딩하나요?

데이터가 함께 읽히고, 배열이 한정되어 있고, 업데이트가 드물 때 임베딩을 권장한다고 스킬은 말합니다.

쿼리 계획은 왜 확인하나요?

운영에 들어가기 전에 실행 통계 검사를 해서 쿼리가 인덱스를 쓰는지 확인하라고 스킬은 권장합니다.

스키마 버전 필드는 왜 추가하나요?

각 문서가 어떤 스키마를 따르는지 알려 주므로, 앞으로의 마이그레이션을 관리하기 쉬워집니다.

상세 정보

작성자의 원본 설명

MongoDB operations expert for queries, aggregation pipelines, indexes, and schema design

repo: RightNow-AI/openfang

인기도

GitHub 스타
18k
순위
#10691
라이선스
Apache-2.0
업데이트
2026. 7. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬