[英]MongoDB find() which is retrieving only one property from the collection
我有一个博客帖子集合,其中记录的结构为{title,author,contents},我想检索我正在执行的所有作者的所有姓名:
this.db.collection("ContentText").find("authors");
但是我的输出是undefined
有人可以指出错误吗?
尝试这个:
this.db.collection("ContentText").distinct("author");
尝试这个:
this.db.collection('<collection_name>').find(<queryObject>,{author:1});
该查询将返回带有_id的作者数组,您可以通过以下方式排除_id
{_id:0,author:1}
欲了解更多,请阅读此
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.