开发者

Possible to return nested elements from Mongodb

Say I have the following structure:

{
    site : [
        page1:
        {
            title: "Page One",
            content: "Content for page one"
            subpages : [
                {
                    title: "Subpage one",
                    content: "Content for subpage one"
                },
                {
                    title: "Subpage two",
                    content: "Content for subpage two"
                },
                {
                    title: "Subpage three",
                    content: "Content for subpage three"
                }
            ]
        },

        page2:
        {
        ...
        },

        page3:
      开发者_开发技巧  {
        ...
        }
    ]
}

I want to retrieve Subpage One's content, i.e. store a large nested structure and retrieve a specific node within that structure based on an xpath-style specifier. I would also like to be able to update that node.

Looking at the docs, I don't think it's possible, but I heard somewhere that it is.


It's not possible - the documentation is right.


This any use to you?

IN: > thing =  { "foo" : "1", "subthing" : {  "bar" : "2",  "subsubthing" : {  "baz" : "3"  }  } }
OUT: {
 "foo" : "1",
 "subthing" : {  "bar" : "2",  "subsubthing" : {  "baz" : "3"  }  }
 }

IN > thing.foo
OUT: "1"

IN: > thing.subthing
OUT: {
 "bar" : "2",
 "subsubthing" : {  "baz" : "3"  }
 }

IN: > thing.subthing.bar
OUT: "2"

IN: > thing.subthing.subsubthing
OUT: {
 "baz" : "3"
 }

IN: > thing.subthing.subsubthing.baz = "4"
"4"
> thing.subthing.subsubthing.baz
"4"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜