首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何在猫鼬中找到数据?

如何在猫鼬中找到数据?
EN

Stack Overflow用户
提问于 2015-05-16 07:18:32
回答 1查看 52关注 0票数 0

我尝试了这个命令,但是它没有输出。我想找到formatted_address与伊利根市,拉瑙德尔北,菲律宾。

Postjob.find({'location.results2.formatted_address':'Iligan City,Lanao del Norte,菲律宾‘}

代码语言:javascript
运行
AI代码解释
复制
{
  "user": ObjectId("5557411628f66792558f60d3"),
  "created": ISODate("2015-05-16T15:06:15.478Z"),
  "map": {
    "zoom": "3",
    "position": "8.22992420109622,124.24962043762207"
  },
  "location": {
    "status": "OK",
    "results": [
      {
        "types": [
          "route"
        ],
        "place_id": "ChIJhbJ4M3N2VTIRR34qr5Bf3OA",
        "geometry": {
          "viewport": {
            "southwest": {
              "lng": 124.24813966971,
              "lat": 8.2281481697085
            },
            "northeast": {
              "lng": 124.25083763029,
              "lat": 8.2308461302915
            }
          },
          "location_type": "APPROXIMATE",
          "location": {
            "lng": 124.2494887,
            "lat": 8.2294971
          },
          "bounds": {
            "southwest": {
              "lng": 124.2494355,
              "lat": 8.229059
            },
            "northeast": {
              "lng": 124.2495418,
              "lat": 8.2299353
            }
          }
        },
        "formatted_address": "Ubaldo Laya Avenue, Iligan City, 9200 Lanao del Norte, Philippines",
        "address_components": [
          {
            "types": [
              "route"
            ],
            "short_name": "Ubaldo Laya Ave",
            "long_name": "Ubaldo Laya Avenue"
          },
          {
            "types": [
              "neighborhood",
              "political"
            ],
            "short_name": "Pala-o",
            "long_name": "Pala-o"
          },
          {
            "types": [
              "locality",
              "political"
            ],
            "short_name": "Iligan City",
            "long_name": "Iligan City"
          },
          {
            "types": [
              "administrative_area_level_2",
              "political"
            ],
            "short_name": "Lanao del Norte",
            "long_name": "Lanao del Norte"
          },
          {
            "types": [
              "administrative_area_level_1",
              "political"
            ],
            "short_name": "Northern Mindanao",
            "long_name": "Northern Mindanao"
          },
          {
            "types": [
              "country",
              "political"
            ],
            "short_name": "PH",
            "long_name": "Philippines"
          },
          {
            "types": [
              "postal_code"
            ],
            "short_name": "9200",
            "long_name": "9200"
          }
        ]
      },
      {
        "types": [
          "neighborhood",
          "political"
        ],
        "place_id": "ChIJTc3qwgx2VTIRu-0j_nFpfMg",
        "geometry": {
          "viewport": {
            "southwest": {
              "lng": 124.2402704,
              "lat": 8.2213317
            },
            "northeast": {
              "lng": 124.2650056,
              "lat": 8.2396977
            }
          },
          "location_type": "APPROXIMATE",
          "location": {
            "lng": 124.2560525,
            "lat": 8.2262687
          },
          "bounds": {
            "southwest": {
              "lng": 124.2402704,
              "lat": 8.2213317
            },
            "northeast": {
              "lng": 124.2650056,
              "lat": 8.2396977
            }
          }
        },
        "formatted_address": "Pala-o, Iligan City, Lanao del Norte, Philippines",
        "address_components": [
          {
            "types": [
              "neighborhood",
              "political"
            ],
            "short_name": "Pala-o",
            "long_name": "Pala-o"
          },
          {
            "types": [
              "locality",
              "political"
            ],
            "short_name": "Iligan City",
            "long_name": "Iligan City"
          },
          {
            "types": [
              "administrative_area_level_2",
              "political"
            ],
            "short_name": "Lanao del Norte",
            "long_name": "Lanao del Norte"
          },
          {
            "types": [
              "administrative_area_level_1",
              "political"
            ],
            "short_name": "Northern Mindanao",
            "long_name": "Northern Mindanao"
          },
          {
            "types": [
              "country",
              "political"
            ],
            "short_name": "PH",
            "long_name": "Philippines"
          }
        ]
      },
      {
        "types": [
          "locality",
          "political"
        ],
        "place_id": "ChIJDVTJKLN5VTIRO9DwoqsI4uY",
        "geometry": {
          "viewport": {
            "southwest": {
              "lng": 124.1653929,
              "lat": 8.002117
            },
            "northeast": {
              "lng": 124.5800686,
              "lat": 8.3233239
            }
          },
          "location_type": "APPROXIMATE",
          "location": {
            "lng": 124.2452422,
            "lat": 8.2280209
          },
          "bounds": {
            "southwest": {
              "lng": 124.1653929,
              "lat": 8.002117
            },
            "northeast": {
              "lng": 124.5800686,
              "lat": 8.3233239
            }
          }
        },
        "formatted_address": "Iligan City, Lanao del Norte, Philippines",
        "address_components": [
          {
            "types": [
              "locality",
              "political"
            ],
            "short_name": "Iligan City",
            "long_name": "Iligan City"
          },
          {
            "types": [
              "administrative_area_level_2",
              "political"
            ],
            "short_name": "Lanao del Norte",
            "long_name": "Lanao del Norte"
          },
          {
            "types": [
              "administrative_area_level_1",
              "political"
            ],
            "short_name": "Northern Mindanao",
            "long_name": "Northern Mindanao"
          },
          {
            "types": [
              "country",
              "political"
            ],
            "short_name": "PH",
            "long_name": "Philippines"
          }
        ]
      },
      {
        "types": [
          "administrative_area_level_2",
          "political"
        ],
        "place_id": "ChIJBXUpcVy5VTIRh-s9Mn1Hh58",
        "geometry": {
          "viewport": {
            "southwest": {
              "lng": 123.621328,
              "lat": 7.6934621
            },
            "northeast": {
              "lng": 124.573305,
              "lat": 8.3414729
            }
          },
          "location_type": "APPROXIMATE",
          "location": {
            "lng": 123.8857747,
            "lat": 7.8721811
          },
          "bounds": {
            "southwest": {
              "lng": 123.621328,
              "lat": 7.6934621
            },
            "northeast": {
              "lng": 124.573305,
              "lat": 8.3414729
            }
          }
        },
        "formatted_address": "Lanao del Norte, Philippines",
        "address_components": [
          {
            "types": [
              "administrative_area_level_2",
              "political"
            ],
            "short_name": "Lanao del Norte",
            "long_name": "Lanao del Norte"
          },
          {
            "types": [
              "administrative_area_level_1",
              "political"
            ],
            "short_name": "Northern Mindanao",
            "long_name": "Northern Mindanao"
          },
          {
            "types": [
              "country",
              "political"
            ],
            "short_name": "PH",
            "long_name": "Philippines"
          }
        ]
      },
      {
        "types": [
          "administrative_area_level_1",
          "political"
        ],
        "place_id": "ChIJjWvt7eRkADMR5MfVbPLs2mM",
        "geometry": {
          "viewport": {
            "southwest": {
              "lng": 123.5556265,
              "lat": 7.3991609
            },
            "northeast": {
              "lng": 125.444464,
              "lat": 9.2580606
            }
          },
          "location_type": "APPROXIMATE",
          "location": {
            "lng": 124.6856509,
            "lat": 8.0201635
          },
          "bounds": {
            "southwest": {
              "lng": 123.5556265,
              "lat": 7.3991609
            },
            "northeast": {
              "lng": 125.444464,
              "lat": 9.2580606
            }
          }
        },
        "formatted_address": "Northern Mindanao, Philippines",
        "address_components": [
          {
            "types": [
              "administrative_area_level_1",
              "political"
            ],
            "short_name": "Northern Mindanao",
            "long_name": "Northern Mindanao"
          },
          {
            "types": [
              "country",
              "political"
            ],
            "short_name": "PH",
            "long_name": "Philippines"
          }
        ]
      },
      {
        "types": [
          "country",
          "political"
        ],
        "place_id": "ChIJY96HXyFTQDIRV9opeu-QR3g",
        "geometry": {
          "viewport": {
            "southwest": {
              "lng": 114.583481,
              "lat": 3.6346296
            },
            "northeast": {
              "lng": 130.6600275,
              "lat": 19.7610407
            }
          },
          "location_type": "APPROXIMATE",
          "location": {
            "lng": 121.774017,
            "lat": 12.879721
          },
          "bounds": {
            "southwest": {
              "lng": 116.7029193,
              "lat": 4.5870339
            },
            "northeast": {
              "lng": 126.6043837,
              "lat": 19.5740241
            }
          }
        },
        "formatted_address": "Philippines",
        "address_components": [
          {
            "types": [
              "country",
              "political"
            ],
            "short_name": "PH",
            "long_name": "Philippines"
          }
        ]
      }
    ]
  },
  "jobdescription": "test",
  "name": "test",
  "__v": NumberInt(0)
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-16 07:31:04

我觉得你的问题是错的。您可以使用$elemMatch(投影)1来解决这个问题。

示例:

代码语言:javascript
运行
AI代码解释
复制
Postjob.find({"user": ObjectId("5557411628f66792558f60d3")}, {"location.results": {$elemMatch: {formatted_address: "Iligan City, Lanao del Norte, Philippines" } } });

希望能帮上忙。

1. http://docs.mongodb.org/manual/reference/operator/projection/elemMatch/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30277364

复制
相关文章

相似问题

领券
社区富文本编辑器全新改版!诚邀体验~
全新交互,全新视觉,新增快捷键、悬浮工具栏、高亮块等功能并同时优化现有功能,全面提升创作效率和体验
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文