我在尝试查询 Mongo 中的字段时遇到了一些麻烦。我的文档如下所示:
{
"short_url": "DTsB9k",
"long_url": "http://www.example.com",
"date_created": {
"$date": "2013-01-01T14:10:29.899Z"
},
"ips": {
"24.184.209.227": {
"ip_address": "12.34.56.78",
"clicks": [
{
"click_date": {
"$date": "2013-01-01T14:10:41.784Z"
},
"click_referrer": null
},
{
"click_date": {
"$date": "2013-01-01T14:31:32.440Z"
},
"click_referrer": null
}
]
}
},
"users": {
"4": {
"user_id": "4",
"date_added": {
"$date": "2013-01-01T14:10:29.899Z"
},
"creator": true
}
},
"total_clicks": 2,
"_id": {
"$oid": "50e2ee55569df0b469000000"
}
}
我正在尝试查询user_id,最终会有不止一个。但我试过了
{ "users" : "4" }
{ "users.user_id" : "4" }
{ "users.*.user_id" : "4" }
这些都不起作用。我在这做错了什么?