# Mongodb

> MongoDB schema design, aggregation pipelines, indexing strategies, and performance.

- Skill: `majiayu000/mongodb-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/mongodb-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/mongodb-2/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/mongodb-2

---


# MongoDB Skill

Expert assistance for MongoDB database design and operations.

## Capabilities

- Design document schemas
- Build aggregation pipelines
- Create optimal indexes
- Implement data modeling patterns
- Configure replication and sharding

## Aggregation Pipeline

```typescript
const results = await collection.aggregate([
  { $match: { status: 'active' } },
  { $group: { _id: '$category', total: { $sum: '$amount' } } },
  { $sort: { total: -1 } },
  { $limit: 10 },
]).toArray();
```

## Indexing

```typescript
// Compound index
await collection.createIndex({ userId: 1, createdAt: -1 });

// Text index
await collection.createIndex({ title: 'text', content: 'text' });
```

## Target Processes

- mern-stack-development
- database-design
- backend-development

