MongoDB 结果返回指定字段

调用查询的find函数

  • 第一个参数为filter,就是过滤,比如我要查age为18的就是 find({age:18}),大于18则 find({age:{$gt:18}})
  • 第二个参数是结果中只需要哪些,只需要asset则find({},{asset: 1}),不需要asset则 find({},{asset: 0})
db.news.find({},{asset: 1})
posted @ 2021-04-12 16:43  HumorChen99  阅读(8)  评论(0编辑  收藏  举报  来源