【发布时间】:2017-11-18 10:35:45
【问题描述】:
我有一个关于 mongodb 的查询问题
我的数据库中有 2 个集合,名称为 status 和 menu
status_id中的主键是menu集合中购买列表的值的外键
对于status 收藏:
{
"_id": "green", "description": "running"
}
{
"_id": "yellow", "description": "prepareing"
}
{
"_id": "black", "description": "closing"
}
{
"_id": "red", "description": "repairing"
}
对于menu 收藏:
{
"name": "tony",
"bought": [
{
"notebook": "green"
},
{
"cellphone": "red"
}
]
}
{
"name": "andy",
"bought": [
{
"fan": "black"
}
]
}
如何查询才能得到以下答案?
(只需将description 替换为_id)
{
"name": "tony",
"bought": [
{
"notebook": "running"
},
{
"cellphone": "repairing"
}
]
}
这是 NoSQL 的子查询问题吗?怎么用关键词去google?
【问题讨论】:
标签: mongodb