假設我在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