MongoDB - 如何从集合中查询嵌入文档
大师 - 我陷入了一种情况,无法弄清楚如何从以下集合“users”中查询,它有 2 个嵌入文档“signup”和“活动”:
{
"appid": 2,
"userid": 404915,
"signup": {
"dt": "2010-12-28",
"platform": 2
},
"activity": {
{
"dt": "2010-12-28",
"platform": 3,
"login_count": 8,
"game_completed": 13
},
{
"dt": "2010-12-30",
"platform": 3,
"login_count": 8,
"game_completed": 13
} ,
{
"dt": "2010-12-31",
"platform": 3,
"login_count": 8,
"game_completed": 13
}
}
},{"appid":2,"userid":404915...}
我需要查询:
在“日期”和“日期+7”之间注册并在“日期”内登录的用户的唯一登录次数
:
在 Date 和 Date+7 之间注册以及在 Date+7 和 Date+14 之间登录的用户的唯一登录信息
请指导我如何实现此任何示例/样本?基于此将非常有帮助:-)
非常感谢!
Gurus - I'm stuck in a situation that I can't figure out how I can query from the following collection "users", it has 2 embedded documents "signup" and "activity":
{
"appid": 2,
"userid": 404915,
"signup": {
"dt": "2010-12-28",
"platform": 2
},
"activity": {
{
"dt": "2010-12-28",
"platform": 3,
"login_count": 8,
"game_completed": 13
},
{
"dt": "2010-12-30",
"platform": 3,
"login_count": 8,
"game_completed": 13
} ,
{
"dt": "2010-12-31",
"platform": 3,
"login_count": 8,
"game_completed": 13
}
}
},{"appid":2,"userid":404915...}
I need to query:
unique logins of users who signed up between Date and Date+7 and logged in within Date
Then:
Unique logins of users who signed up between Date and Date+7, and logged in between Date+7 and Date+14
PLEASE PLEASE Guide me how I can achieve this any example/sample? based on this will be really helpful :-)
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是获取第一个查询结果的方法:
第二个查询与活动后日期的开始日期和结束日期添加 7 天类似。
Here is how you get the result for your first query:
The second is like it with adding 7 days to the start and end date to the dates after activity.