mongodb
Use for managing MongoDB.
When & Why to Use This Skill
This Claude skill provides a powerful interface for managing MongoDB databases, enabling users to execute complex queries, perform batch updates, and explore data schemas through natural language commands. By leveraging a TypeScript-based execution environment, it streamlines database administration tasks, supports advanced operations like ObjectId handling and parallel processing, and optimizes token usage for efficient AI-driven data management.
Use Cases
- Schema Exploration: Quickly inspect collection structures using findOne() or limit(1) to understand data models without excessive resource consumption.
- Data Maintenance: Execute batch updates or deletions across multiple collections simultaneously using Promise.all for high-efficiency database cleanup.
- Complex Querying: Retrieve specific documents using global ObjectId support and perform existence checks with countDocuments() to minimize data transfer.
- Automated Data Workflows: Implement multi-step logic and asynchronous operations via IIFEs to handle sophisticated data transformation tasks directly within the chat interface.
| name | mongodb |
|---|---|
| description | Use for managing MongoDB. |
Usage
bun {dir}/scripts/query.ts "<query>"
Examples
# Simple read
bun {dir}/scripts/query.ts "db.collection('users').findOne()"
# Query with ObjectId
bun {dir}/scripts/query.ts "db.collection('users').findOne({ _id: new ObjectId('...') })"
# Multi-step update (Batching)
bun {dir}/scripts/query.ts "Promise.all([
db.collection('rewards').deleteMany({ userId: new ObjectId('...') }),
db.collection('users').updateOne({ _id: new ObjectId('...') }, { \$set: { 'dailyXp.count': 0 } })
])"
Tips
- Use query.ts over writing one-off scripts. Use
Promise.allfor parallel operations or an IIFE(async () => { ... })()for complex multi-step logic. ObjectIdis globally available in the query context.- Use
limit(1)orfindOne()to understand schema without wasting tokens. - Use
countDocuments()instead of fetching docs for existence checks.