
mongoose-mongodb
Work with MongoDB in Node.js using Mongoose ODM for schema design, CRUD operations, relationships, and advanced queries
- Installs
- 694
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-nodejs --skill mongoose-mongodb- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads mongoose-mongodb automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Mongoose & MongoDB Skill
Master MongoDB database integration in Node.js with Mongoose, the elegant object modeling library.
Quick Start
Connect and CRUD in 4 steps:
- Install -
npm install mongoose - Connect -
mongoose.connect(uri) - Define Schema - Create data models
- CRUD - Create, Read, Update, Delete
Core Concepts
Connection Setup
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URI, {
useNewUrlParser: true,
useUnifiedTopology: true
});
mongoose.connection.on('connected', () => {
console.log('MongoDB connected');
});
Schema & Model
const userSchema = new mongoose.Schema({
name: {
type: String,
required: [true, 'Name is required'],
trim: true,
minlength: 3,
maxlength: 50
},
email: {
type: String,
required: true,
unique: true,
lowercase: true
},
age: {
type: Number,
min: 18,
max: 120
},
role: {
type: String,
enum: ['user', 'admin'],
default: 'user'
}
}, {
timestamps: true // createdAt, updatedAt
});
const User = mongoose.model('User', userSchema);
CRUD Operations
// Create
const user = await User.create({
name: 'John Doe',
email: 'john@example.com'
});
// Read
const users = await User.find({ age: { $gte: 18 } });
const user = await User.findById(id);
const user = await User.findOne({ email: 'john@example.com' });
// Update
const updated = await User.findByIdAndUpdate(
id,
{ name: 'Jane Doe' },
{ new: true, runValidators: true }
);
// Delete
await User.findByIdAndDelete(id);
await User.deleteMany({ age: { $lt: 18 } });
Relationships & Population
const postSchema = new mongoose.Schema({
title: String,
content: String,
author: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
}
});
// Populate relationship
const post = await Post.findById(id).populate('author');
// post.author is now full user object
Learning Path
Beginner (2-3 weeks)
- ✅ Install MongoDB and Mongoose
- ✅ Create schemas and models
- ✅ CRUD operations
- ✅ Basic queries
Intermediate (4-5 weeks)
- ✅ Relationships and population
- ✅ Validation and middleware
- ✅ Indexes for performance
- ✅ Query operators
Advanced (6-8 weeks)
- ✅ Aggregation pipelines
- ✅ Transactions
- ✅ Schema design patterns
- ✅ Performance optimization
Advanced Features
Indexes
userSchema.index({ email: 1 }, { unique: true });
userSchema.index({ name: 1, age: -1 });
Middleware (Hooks)
userSchema.pre('save', async function(next) {
if (this.isModified('password')) {
this.password = await bcrypt.hash(this.password, 10);
}
next();
});
Virtual Properties
userSchema.virtual('fullName').get(function() {
return `${this.firstName} ${this.lastName}`;
});
Aggregation Pipeline
const stats = await User.aggregate([
{ $match: { age: { $gte: 18 } } },
{ $group: {
_id: '$role',
count: { $sum: 1 },
avgAge: { $avg: '$age' }
}},
{ $sort: { count: -1 } }
]);
Query Operators
// Comparison
User.find({ age: { $gt: 18 } }) // Greater than
User.find({ age: { $gte: 18 } }) // Greater or equal
User.find({ age: { $lt: 65 } }) // Less than
User.find({ age: { $lte: 65 } }) // Less or equal
User.find({ age: { $ne: 30 } }) // Not equal
// Logical
User.find({ $and: [{ age: { $gte: 18 } }, { age: { $lte: 65 } }] })
User.find({ $or: [{ role: 'admin' }, { role: 'moderator' }] })
// Array
User.find({ tags: { $in: ['node', 'mongodb'] } })
User.find({ tags: { $nin: ['deprecated'] } })
// Regex
User.find({ email: /gmail\.com$/ })
Best Practices
- ✅ Use environment variables for connection strings
- ✅ Create indexes for frequently queried fields
- ✅ Use
lean()for read-only queries (better performance) - ✅ Validate data at schema level
- ✅ Use transactions for multi-document operations
- ✅ Handle connection errors properly
- ✅ Close connections on app shutdown
When to Use
Use MongoDB with Mongoose when:
- Building Node.js applications
- Need flexible schema (document-based)
- Handling large volumes of data
- Rapid prototyping and iteration
- Working with JSON-like data
Related Skills
- Express REST API (connect to MongoDB)
- Async Programming (async database operations)
- JWT Authentication (store users)
- Jest Testing (test database operations)
Resources
FAQ
What does the mongoose-mongodb skill do?
Work with MongoDB in Node.js using Mongoose ODM for schema design, CRUD operations, relationships, and advanced queries
How do I install mongoose-mongodb?
Run npx skills add https://github.com/pluginagentmarketplace/custom-plugin-nodejs --skill mongoose-mongodb in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/mongoose-mongodb/ (personal) or .claude/skills/mongoose-mongodb/ (project).
Which AI agents can use mongoose-mongodb?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is mongoose-mongodb safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains mongoose-mongodb?
It is published by pluginagentmarketplace in pluginagentmarketplace/custom-plugin-nodejs. It has 694 recorded installs.
More from pluginagentmarketplace/custom-plugin-nodejs
express-rest-api
pluginagentmarketplace/custom-plugin-nodejs
Build production-ready RESTful APIs with Express.js including routing, middleware, validation, and error handling for scalable backend services
docker-deployment
pluginagentmarketplace/custom-plugin-nodejs
Containerize and deploy Node.js applications with Docker including multi-stage builds, Docker Compose, and production optimization
jwt-authentication
pluginagentmarketplace/custom-plugin-nodejs
Open the skill to read its SKILL.md instructions.
jest-testing
pluginagentmarketplace/custom-plugin-nodejs
Open the skill to read its SKILL.md instructions.
async-patterns
pluginagentmarketplace/custom-plugin-nodejs
Open the skill to read its SKILL.md instructions.
websockets
pluginagentmarketplace/custom-plugin-nodejs
Open the skill to read its SKILL.md instructions.
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.