Master MongoDB CRUD operations, document insertion, querying, updating, and deletion. Learn BSON format, ObjectId, data types, and basic operations. Use when working with documents, collections, and fundamental MongoDB operations.
Executes MongoDB CRUD operations using official drivers. Triggers when creating, reading, updating, or deleting documents in MongoDB collections, handling BSON types and ObjectId generation.
/plugin marketplace add pluginagentmarketplace/custom-plugin-mongodb/plugin install mongodb-developer-plugin@pluginagentmarketplace-mongodbThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlreferences/GUIDE.mdscripts/helper.pyMaster fundamental MongoDB Create, Read, Update, Delete operations.
const { MongoClient } = require('mongodb');
const client = new MongoClient('mongodb://localhost:27017');
await client.connect();
const db = client.db('myapp');
const users = db.collection('users');
// Insert one document
const result = await users.insertOne({
name: 'John Doe',
email: 'john@example.com',
age: 30,
createdAt: new Date()
});
console.log('Inserted ID:', result.insertedId);
// Insert multiple documents
await users.insertMany([
{ name: 'Alice', email: 'alice@example.com' },
{ name: 'Bob', email: 'bob@example.com' }
]);
// Find one document
const user = await users.findOne({ email: 'john@example.com' });
// Find all documents
const allUsers = await users.find({}).toArray();
// Find with filter
const activeUsers = await users.find({ status: 'active' }).toArray();
// Find by ObjectId
const { ObjectId } = require('mongodb');
const user = await users.findOne({ _id: new ObjectId('...') });
// Update one document
const result = await users.updateOne(
{ email: 'john@example.com' },
{ $set: { age: 31, updatedAt: new Date() } }
);
// Update multiple documents
await users.updateMany(
{ status: 'inactive' },
{ $set: { lastNotified: new Date() } }
);
// Replace entire document
await users.replaceOne(
{ _id: userId },
{ name: 'New Name', email: 'new@example.com' }
);
// Delete one document
await users.deleteOne({ email: 'john@example.com' });
// Delete multiple documents
await users.deleteMany({ status: 'deleted' });
// Delete all documents (careful!)
await users.deleteMany({});
// String
{ name: 'John' }
// Number (int32, int64, double)
{ age: 30, price: 19.99 }
// Boolean
{ isActive: true }
// Date
{ createdAt: new Date() }
// Array
{ tags: ['mongodb', 'database', 'nosql'] }
// Object (embedded document)
{ address: { city: 'New York', zip: '10001' } }
// ObjectId (default _id field)
{ _id: ObjectId('507f1f77bcf86cd799439011') }
// Null
{ description: null }
// Binary Data
{ image: Buffer.from('data') }
// Regular Expression
{ email: /.*@example\.com/ }
from pymongo import MongoClient
from datetime import datetime
client = MongoClient('mongodb://localhost:27017')
db = client['myapp']
users = db['users']
# Insert
result = users.insert_one({
'name': 'John',
'email': 'john@example.com',
'createdAt': datetime.now()
})
# Read
user = users.find_one({'email': 'john@example.com'})
# Update
users.update_one(
{'_id': result.inserted_id},
{'$set': {'age': 30}}
)
# Delete
users.delete_one({'_id': result.inserted_id})
✅ Always handle errors with try-catch ✅ Use connection pooling ✅ Close connections properly ✅ Use ObjectId for _id fields ✅ Validate data before insertion ✅ Use appropriate write concerns ✅ Index frequently queried fields ✅ Plan for schema evolution
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.