假设我在MongoDB中有一个像下面这样的JSON对象作为集合中的一个项目。搜索MongoDB嵌套树对象
data:{
name:"newData",
items:
[
{
"id": 1,
"title": "1. dragon-breath",
"items": []
},
{
"id": 2,
"items": [
{
"id": 21,
"title": "2.1. tofu-animation",
"items": [
{
"id": 211,
"title": "2.1.1. spooky-giraffe",
"items": []
},
{
"id": 212,
"items": []
}
]
},
{
"id": 22,
"title": "2.2. barehand-atomsplitting",
"items": []
}
]
},
{
"id": 3,
"title": "3. unicorn-zapper",
"items": [
{
"id": 30,
"title": "3. unicorn-zapper.1",
"items": [
{
"id": 300,
"title": "3. unicorn-zapper.1.1",
"items": [
{
"id": 3000,
"title": "3. unicorn-zapper.1.1.1",
"items": [
{
"id": 30000,
"title": "3. unicorn-zapper.1.1.1.1",
"items": [
{
"id": 300000,
"title": "3. unicorn-zapper.1.1.1.1.1",
"items": []
}
]
}
]
}
]
}
]
}
]
},
{
"id": 4,
"title": "4. romantic-transclusion",
"items": []
}
]
它是一个连续的树结构,所有项目不一定需要具有“标题”属性。如何在整个结构中搜索标题为例如{“title”:“3。unicorn-zapper.1.1.1”}的项目并仅返回该项目。有任何想法吗。
这不是外包门户,在那里你转储你的工作,其他人为你做。显示一些功能,然后寻求帮助 – 2014-10-11 06:25:53