mongodb的查询命令

db.collection.find()

db.collection.find({属性:值})

db.collection.findOne()

查询集合中符合条件的所有的文档:

db.stus.find();//返回数组,里面有多个对象

db.stus.find({});

db.stus.find({_id:"hello"});

db.stus.find({age:28});

db.stus.find({age:28})[0];

db.stus.find({age:16,name:"白骨精"});

db.stus.findOne({age:28}).name;//返回一个对象

db.stus.find({}).count();

db.stus.find({}).length();

posted on 2023-02-13 21:03  sunny_2016  阅读(421)  评论(0)    收藏  举报

导航