文章最后更新时间:
【免责声明:本文由AI辅助生成,内容仅供参考,不构成专业建议。】
MongoDB核心概念
MongoDB是流行的NoSQL文档数据库,以灵活的JSON-like文档存储数据,适合快速迭代和大数据场景。
核心概念对比
- Database ≈ 数据库
- Collection ≈ 表(无固定schema)
- Document ≈ 记录(BSON格式)
- Field ≈ 字段
常用操作
// 插入文档
db.users.insertOne({
name: "张三",
email: "zhangsan@example.com",
age: 28,
tags: ["developer", "blogger"]
});
// 查询文档
db.users.find({ age: { $gte: 18 } });
// 聚合管道
db.orders.aggregate([
{ $match: { status: "completed" } },
{ $group: { _id: "$category", total: { $sum: "$amount" } } },
{ $sort: { total: -1 } }
]);
适用场景
- 内容管理系统
- 实时分析
- 物联网数据存储
- 移动应用后端
更多技术文章:https://blog.hanyucloud.com | 客服:400-880-3980
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END

















- 最新
- 最热
查看全部