条件$or或关系$nor或关系否定$gt大于$gte大于等于$lt小于$lte小于等于$ne不等于$in$nin不在多个值范围内多个取值范围$all匹配数组中的多个值$regex正则,用于模糊查询$size匹配数组大小$maxDistance范围查询,距离(基于LBS)$mod 取模操作$near邻域查询,查询附近位置(基于LBS)$exists字段是否存在$elemMatch匹配数组中的元素$within范围查询(基于LBS)$box范围查询,矩形范围(基于LBS)$centerrange唤醒查询,圆形范围(基于LBS)$centerSphere范围查询,球形范围(基于LBS)$slice查询字段集合中的元素(比如从数字后第N到第M个元素#find()##find({"this.name=='a'"})Model.find(conditions,[fields],[options],[callback])注:conditions查询条件,fields要查询的字段,options,callback回调函数示例:查询下面的用户表从第二个张三开始的最后两个文档只需要按创建时间倒序显示姓名、性别、居住地址和创建时间信息即可。//对象写法userModel.find({'name':'张三'},{'name':1,'sex':1,'region':1,'createBy':1,'_id':0},{limit:2,skip:1,sort:'-createBy.createTime'})//链写userModel.find({'name':'张三'},{'name':1,'sex':1,'区域':1,'创建eBy':1,'_id':0}).skip(7).limit(2).sort({'createBy.createTime':-1})返回结果:##find({$where:"this.name=='a'"})Model.$where('this.firstname===this.lastname').exec(callback)##where复杂查询Model.where('age').gte(25)。where('tags').in(['movie','music','art']).select('name','age','tags').skip(20).limit(10).asc('age').slaveOk().hint({age:1,name:1}).run(callback);##查询非空字段Model.find(conditions:{$exists:true})Model.find(conditions:{$ne:null})##分页查询Model.find(conditions).skip(pageTotal*pageNum).limit(pageTotal).sort({'_id':-1}).exec(cb);注:condition查询条件,pageTotal为每页显示的item数,pageNum为页数,cb为回调函数##模糊查询userModel.find({"name":{$regex:'prawn'}})userModel.find({"name":/prawn/}})returnsresult:#findById()Model.findById(conditions,[fields],[options],[callback])和Model.find一样,但是它接收文档id的_作为参数,返回单个文档_id可以是字符串或ObjectId对象。#findOne()Model.find(conditions,[fields],[options],[callback])和Model.find一样,只是返回第一个满足条件的文档注解:参考文档Mongoose基础入门
