Mongodb Guide Skill logo

Mongodb Guide Skill

Community
jiushiwon
mongodb-guide-skill

MongoDB 学习与选型指南。面向需要了解 MongoDB 的开发者,提供核心概念、安装部署、文档模型设计、CRUD、聚合查询、索引优化、与业务场景匹配推荐等(不含具体框架集成)。触发词:"MongoDB 学习"、"MongoDB 入门"、"MongoDB 选型"、"MongoDB 概念"、"MongoDB 安装"、"文档数据库"、"mongodb 设计"。

Overview

Publisherjiushiwon
Repositorywg-skills
Skill namemongodb-guide-skill
Stars
123
Forks
38
Bundled files
3
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by jiushiwon on GitHub. Read the source before you install it.

Installation

Install the Mongodb Guide Skill AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/database/mongodb-guide-skill
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jiushiwon/wg-skills.git /tmp/wg-skills
mkdir -p .claude/skills
cp -r /tmp/wg-skills/vibeCoding/backend/database/mongodb-guide-skill .claude/skills/mongodb-guide-skill
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Mongodb Guide Skill in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Mongodb Guide Skill on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Mongodb Guide Skill is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

MongoDB Module Skill

面向已有后端项目的开发者,快速集成 MongoDB 能力。

能力清单

能力说明
连接配置MongoClient/连接池/环境变量配置
文档模型Document/Entity 设计
CRUD 操作增删改查/批量操作
聚合查询Match/Group/Lookup/Pipeline
索引优化索引设计/慢查询优化
事务处理多文档事务

触发场景

用户说"帮我加 MongoDB"或"集成 MongoDB"时触发。

核心配置

Java (Spring Boot)

yaml
# application.yml
spring:
  data:
    mongodb:
      uri: mongodb://${MONGO_HOST:localhost}:${MONGO_PORT:27017}/${MONGO_DATABASE:myapp}
      uuid-representation: standard

Python (FastAPI)

python
# config.py
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    mongo_host: str = "localhost"
    mongo_port: int = 27017
    mongo_database: str = "myapp"

# database.py
from motor.motor_asyncio import AsyncIOMotorClient

client = AsyncIOMotorClient(f"mongodb://{host}:{port}")
db = client[database]

Go (Gin + mongo-driver)

go
// config/config.go
package config

import (
    "fmt"
    "os"
)

type Config struct {
    MongoHost     string
    MongoPort     string
    MongoDatabase string
}

func Load() *Config {
    return &Config{
        MongoHost:     getEnv("MONGO_HOST", "localhost"),
        MongoPort:     getEnv("MONGO_PORT", "27017"),
        MongoDatabase: getEnv("MONGO_DATABASE", "myapp"),
    }
}

func (c *Config) URI() string {
    return fmt.Sprintf("mongodb://%s:%s", c.MongoHost, c.MongoPort)
}

func getEnv(key, defaultVal string) string {
    if val := os.Getenv(key); val != "" {
        return val
    }
    return defaultVal
}
go
// database/database.go
package database

import (
    "context"
    "fmt"
    "log"
    "time"

    "go.mongodb.org/mongo-driver/mongo"
    "go.mongodb.org/mongo-driver/mongo/options"
    "go.mongodb.org/mongo-driver/mongo/readpref"
)

var (
    Client *mongo.Client
    DB     *mongo.Database
)

func Init(uri, dbName string) {
    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
    defer cancel()

    var err error
    Client, err = mongo.Connect(ctx, options.Client().ApplyURI(uri))
    if err != nil {
        log.Fatalf("连接 MongoDB 失败: %v", err)
    }

    if err = Client.Ping(ctx, readpref.Primary()); err != nil {
        log.Fatalf("Ping MongoDB 失败: %v", err)
    }

    DB = Client.Database(dbName)
    fmt.Println("MongoDB 连接成功")
}

func Close() {
    if Client != nil {
        ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
        defer cancel()
        Client.Disconnect(ctx)
    }
}

文档模型设计

基础文档模板

java
@Document(collection = "users")
public class User {
    @Id
    private String id;
    
    @Field("username")
    private String username;
    
    @Field("password")
    private String password;
    
    @Field("nickname")
    private String nickname;
    
    @Field("status")
    private Integer status = 1;
    
    @Field("created_at")
    private LocalDateTime createdAt;
    
    @Field("updated_at")
    private LocalDateTime updatedAt;
}

Python (Motor)

python
from pydantic import BaseModel
from datetime import datetime
from typing import Optional

class User(BaseModel):
    username: str
    password: str
    nickname: Optional[str] = None
    status: int = 1
    created_at: datetime = datetime.now()
    updated_at: datetime = datetime.now()
    class Config:
        collection = "users"

CRUD 操作

Java

java
@Repository
public class UserRepository {
    
    @Autowired
    private MongoTemplate mongoTemplate;
    
    // 创建
    public User save(User user) {
        return mongoTemplate.save(user);
    }
    
    // 查询
    public User findById(String id) {
        return mongoTemplate.findById(id, User.class);
    }
    
    public List<User> findByStatus(Integer status) {
        Query query = new Query(Criteria.where("status").is(status));
        return mongoTemplate.find(query, User.class);
    }
    
    // 更新
    public long update(User user) {
        Query query = new Query(Criteria.where("_id").is(user.getId()));
        Update update = new Update()
            .set("nickname", user.getNickname())
            .set("updated_at", LocalDateTime.now());
        return mongoTemplate.updateFirst(query, update, User.class).getModifiedCount();
    }
    
    // 删除
    public long deleteById(String id) {
        Query query = new Query(Criteria.where("_id").is(id));
        return mongoTemplate.remove(query, User.class).getDeletedCount();
    }
}

Python

python
# CRUD 操作
async def create_user(user: User):
    result = await db.users.insert_one(user.dict())
    return result.inserted_id

async def find_user(username: str):
    return await db.users.find_one({"username": username})

async def list_users(status: int = 1):
    cursor = db.users.find({"status": status})
    return await cursor.to_list(length=100)

async def update_user(user_id: str, nickname: str):
    result = await db.users.update_one(
        {"_id": user_id},
        {"$set": {"nickname": nickname, "updated_at": datetime.now()}}
    )
    return result.modified_count

async def delete_user(user_id: str):
    result = await db.users.delete_one({"_id": user_id})
    return result.deleted_count

聚合查询

Java

java
public List<UserStat> getUserStats() {
    Aggregation aggregation = Aggregation.newAggregation(
        Match(Criteria.where("status").is(1)),
        Group("status")
            .count().as("total")
            .avg("age").as("avgAge"),
        Project().andExclude("_id").and("status").as("status")
    );
    return mongoTemplate.aggregate(aggregation, "users", UserStat.class).getMappedResults();
}

Python

python
async def get_user_stats():
    pipeline = [
        {"$match": {"status": 1}},
        {"$group": {
            "_id": "$status",
            "total": {"$sum": 1},
            "avg_age": {"$avg": "$age"}
        }}
    ]
    cursor = db.users.aggregate(pipeline)
    return await cursor.to_list(length=100)

索引优化

java
// 创建索引
@CompoundIndex(def = "{'username': 1}", unique = true)
@CompoundIndex(def = "{'status': 1, 'created_at': -1}")
public class User {
    // ...
}
python
# Python
await db.users.create_index("username", unique=True)
await db.users.create_index([("status", 1), ("created_at", -1)])

不做

  • 不负责 MongoDB Server 安装(用户自行安装或使用 Docker)
  • 不处理复杂的集群配置(副本集、分片)
  • 不提供数据迁移工具

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Mongodb Guide Skill AI skill do?

MongoDB 学习与选型指南。面向需要了解 MongoDB 的开发者,提供核心概念、安装部署、文档模型设计、CRUD、聚合查询、索引优化、与业务场景匹配推荐等(不含具体框架集成)。触发词:"MongoDB 学习"、"MongoDB 入门"、"MongoDB 选型"、"MongoDB 概念"、"MongoDB 安装"、"文档数据库"、"mongodb 设计"。

Why use Mongodb Guide Skill on TypingMind?

Because you install it once and use it with any model. Mongodb Guide Skill is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Mongodb Guide Skill in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/database/mongodb-guide-skill. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Mongodb Guide Skill?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Mongodb Guide Skill?

As many as you like. As long as a model supports skills, you can use Mongodb Guide Skill with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Mongodb Guide Skill AI skill free?

Yes. It is published on GitHub by jiushiwon under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇