繁体   English   中英

如何在mongodb中检索字段的所有值?

[英]How to retrieve all the values of field in mongodb?

这是我在Mongodb中收集的示例

{
  "_id":ObjectId("54076c79f764e4ea431bf7f6"),
  "trends":[
  {
    "query":"%23Ces aroni",
    "name":"#Cesaroni",
    "url":"http://twitter.com/search?q=%23Cesaroni",
    "promoted_content":null
  },
  {
    "query":"%23MelihG%C3%B6kcekKKy%C4%B1De%C5%9Fi freEdiyor",
    "name":"#MelihGökcekKKyiDesifreEdiyor",
    "url":"http://twitter.co m/search?q=%23MelihG%C3%B6kcekKKy%C4%B1De%C5%9FifreEdiyor",
    "promoted_content":null
  },
  {
    "query":"%23EngvNor",
    "name":"#EngvNor",
    "url":"http://twitter. com/search?q=%23EngvNor",
    "promoted_content":null
  },
  "locations":[
  {
    "woeid":1,
    "name":"Worldwide"
  }
  ],
  "created_at":"2014-09-03T19:23:55Z",
  "as_of":"2014-09-03T19:31:05Z"
}

该集合将从Twitter检索到时转储到mongodb集合。 现在,我想为其他位置添加更多数据。 由于这是我第一次使用mongodb,因此我无法弄清楚如何仅检索locations字段。

将投影与空查询或过滤查询一起使用:

db.collectionName.find({},{locations:1})

将检索如下内容:

{
"_id" : ObjectId("5407a0a9b7a33063850f5b09"),
"locations" : [
    {
        "woeid" : 1,
        "name" : "Worldwide"
    }
]
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM