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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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
schemaVersionfield to support future migrations.
Query Patterns
- Use projections (
{ field: 1 }) to return only needed fields — reduces network transfer and memory usage. - Use
$elemMatchfor querying and projecting specific array elements. - Use
$infor matching against a list of values. Use$existsand$typefor schema variations. - Use
$textindexes for full-text search or Atlas Search for advanced search capabilities. - Avoid
$whereand 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
$matchas early as possible in the pipeline to reduce the working set. - Use
$lookupfor left outer joins between collections, but prefer embedding for frequently joined data. - Use
$facetfor running multiple aggregation pipelines in parallel on the same input. - Use
$mergeor$outto 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()anddb.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
$regexwith 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.
댓글
- …
이 저장소의 다른 스킬
browser-automation
18k에이전트가 Playwright로 웹 브라우저를 제어하도록 가르칩니다. CSS 선택자로 버튼, 양식, 링크를 찾습니다.
clip-hand-skill
18k에이전트가 영상 클립을 만들도록 돕습니다. 영상을 내려받고, 음성을 텍스트로 옮기고, 자막 파일을 만들고, ffmpeg로 클립을 자릅니다.
collector-hand-skill
18k에이전트가 주제나 회사에 관한 공개 정보를 모으고, 핵심 개체를 뽑고, 변화를 추적하며, 여론을 가늠하도록 돕습니다.
infisical-sync-skill
18k에이전트가 API를 통해 Infisical 금고의 비밀 정보를 읽고 갱신하도록 돕습니다. 로그인 단계와 명확한 오류 처리를 포함합니다.
비슷한 스킬
discrawl
394k에이전트가 저장된 로컬 Discord 메시지 보관본을 검색하고 요약하며, 최신 상태를 확인하고 다이렉트 메시지를 읽도록 돕습니다.
clickhouse-io
280k에이전트가 ClickHouse 데이터베이스의 쿼리와 스키마를 최적화하도록 돕습니다. 고성능 분석 작업의 모범 사례를 적용합니다. 분석 쿼리가 느릴 때 씁니다.
scientific-db-pubmed-database
280k생의학 분야의 과학 논문을 에이전트가 검색하도록 돕습니다. 특정 의학 정보가 필요한 연구에 유용합니다.