mongodb

Use for managing MongoDB.

$ Installer

git clone https://github.com/rakibdev/dotfiles /tmp/dotfiles && cp -r /tmp/dotfiles/home/.config/opencode/skill/mongodb ~/.claude/skills/dotfiles

// tip: Run this command in your terminal to install the skill


name: mongodb description: Use for managing MongoDB.

Usage

bun {base dir}/scripts/query.ts "<query>"

Examples

# Simple read
bun {base dir}/scripts/query.ts "db.collection('users').findOne()"

# Query with ObjectId
bun {base dir}/scripts/query.ts "db.collection('users').findOne({ _id: new ObjectId('...') })"

# Multi-step update (Batching)
bun {base 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.all for parallel operations or an IIFE (async () => { ... })() for complex multi-step logic.
  • ObjectId is globally available in the query context.
  • Use limit(1) or findOne() to understand schema without wasting tokens.
  • Use countDocuments() instead of fetching docs for existence checks.