4、查询文档02

//$gt是大于的意思,$lt是小于的意思
Course.find({age:{$gt:20,$lt:40}}).then(result=>{console.log(result)})
//$in包含的意思,差爱好里包含足球的字段
Course.find({hobbies:{$in:['足球']}}).then(result=>{console.log(result)})
//只查询名字邮箱,不查询ID,不查询的在前面用‘=’标出
Course.find().select('name email -_id').then(result=>{console.log(result)})
//根据年龄字段进行升序排序
Course.find().sort('age').then(result=>{console.log(result)})
//降序排列,在前面加‘-’
Course.find().sort('-age').then(result=>{console.log(result)})
原文地址:https://www.cnblogs.com/tilyougogannbare666/p/14463144.html