ちょうきょう666

导航

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)})

 

posted on 2021-03-01 13:41  ちょうきょう666  阅读(31)  评论(0编辑  收藏  举报