![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
mongodb
婧狗
这个作者很懒,什么都没留下…
展开
-
MongoDB - mongoose:Schema与Model,CURD操作
mongoose API Docs1 Require & Connectvar mongoose = require('mongoose');mongoose.connect('mongodb://127.0.0.1/db_name', {useNewUrlParser: true});2 Define Schema创建Schema对象var Schema = mongoose.Schema;var stuSchema = new Schema({ name: String,原创 2020-10-02 18:02:22 · 426 阅读 · 0 评论 -
MongoDB - 聚合运算:group(), aggregate(), mapReduce()
1 区别group() - 分组统计aggregate() - 简单聚合mapReduce() - 强大统计group 需要手写聚合函数的业务逻辑group 不支持分布式运算分布式可以用 aggregate (version 2.2)或者 mapReduce (version 2.4)2 语法group()db.collection_name.group({ key: {key1: 1, key2: 2}, //分组字段 cond: {}, //查询条件 reduce: f原创 2020-10-02 15:21:39 · 409 阅读 · 0 评论