摘要:
--启动命令 mongod --dbpath D:/MongoDB/data 阅读全文
摘要:
创建counters集合保存每次通过函数更新过的值, /* counters */ { "_id" : "id", "current_value" : 62.0 } 利用counters集合做序列递增操作,findAndModify()可以保证操作的原子性 //调用db.system.js.inse 阅读全文
摘要:
//对成绩集合做聚合,分组,管道操作 db.student.aggregate( [ {$lookup:{from: "score",localField: "_id",foreignField: "stuId",as: "results"}}, // 执行1,结果给2 {$match:{"resu 阅读全文
摘要:
//多集合关联查询,product集合关联orders集合,使用$lookup做集合之间的关联 //集合之间设计不太合理,说明问题即可 /* product集合 */{ "_id" : 1.0, "name" : "草莓", "type" : "水果" } { "_id" : 2.0, "name" 阅读全文
摘要:
查询全部文档 db.getCollection('user').find({}) 条件查询:db.集合.find({"查询条件"},{"指明需要查询出来的字段【1:显示,0:不显示】"}) mongo查询:db.user.find({"age": {$gte: 21}}, {"age": 1,"na 阅读全文
摘要:
score是已经创建的集合db.score.insert({"_id": 103, "subject": "语文", "score": 55, "stuId": 1002}) db.score.save({"_id": 102, "subject": "数学", "score": 80, "stuI 阅读全文