数据查询操作---------基本查询
1.查询所有的数据: db.xx.find()
2.指定条件查询 db.xx.find(查询条件)
3. 只查找符合条件的一个 db.xx.findOne()
4.pretty(): 将结果格式化 db.stu.findOne({gender:true}).pretty()
比较运算符的使用
小于:$lt 小于等于:$lte 大于:$gt 大于等于:$gte 不等于:$ne
例:查询年龄大于18的所有学生
db.stu.find({age:{$gte:18}})
逻辑运算符的使用
-
逻辑运算符主要指与、或逻辑
语法:db.xx.find({$and:[{条件1},{条件2}]})
$and: "查询年龄大于或等于18, 并且性别为true的学生"
用法一: db.stu.find({age:{$gte:18},gen