Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问clear审计通过

mongoose-mongodbmongoose MongoDB 搜索

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

11,432

周安装

467

GitHub Stars

2

下载量

3,699
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:mongoose-mongodb(mongoose MongoDB 搜索)
来源仓库:https://github.com/pluginagentmarketplace/custom-plugin-nodejs
仓库路径:skills/mongoose-mongodb
安装命令:
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-nodejs --skill mongoose-mongodb
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-nodejs --skill mongoose-mongodb

简介

Node.js 中的 MongoDB 对象建模,具有架构验证、关系和高级查询。

  • 涵盖架构设计、字段验证、CRUD 操作以及通过引用和填充进行关系管理
  • 包括用于复杂数据转换的中间件挂钩、虚拟属性、索引和聚合管道
  • 支持跨文档过滤、逻辑运算和正则表达式匹配的查询运算符
  • 最佳实践包括基于环境的连接管理、性能精益查询以及多文档操作的事务支持

SKILL.md

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:

  1. Install - npm install mongoose
  2. Connect - mongoose.connect(uri)
  3. Define Schema - Create data models
  4. 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

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Antigravity

31.3%
按下载量换算1,158

Claude Code

23.75%
按下载量换算879

OpenCode

18.06%
按下载量换算668

Gemini CLI

11.42%
按下载量换算422

Cursor

7.15%
按下载量换算264

github-copilot

3.21%
按下载量换算119

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills