tags:

views:

40

answers:

1

I have a collection as follows:

{ "_id" : ObjectId("4c9c63a95d765f996ca8dff4"), "count" : "28", "id" : "5565", "person" : [
    {
        "id" : "5435df",
        "name" : {
            "fn" : "abc",
            "ln" : "xyz"
        },
        "sex" : "m",
        "location" : {
            "country" : "india"
        }

    },
    {
        "id" : "dfg434",
        "name" : {
            "fn" : "def",
            "ln" : "pqr"
        },
        "sex" : "f",
        "location" : {

            "country" : "india"
        }

    }
.
.
.

]
}

the person is an array, with mentioned fields. i wish to find people with a particular id AND country. only those "people" records should be returned. How do i go about doing that? I am using java. Is the structure correct? Should I change the array structure, into something else?

thanks.

EDIT: How do access rules change when brackets change, in this case, i have used [], where i could have used {}. what changes?

+1  A: 

See "Array" header

luckytaxi
that did not help :( do you have another example (in java)? or maybe a bug on jira to show that its not possible? TIA
Swapnil Sonawane
Using a forEach for each nesting of array works. but what I wish, is to return a particular block, when some data inside it is what i want. eg: person.country== "india" should return blocks with id:5435df and id: dfg434.
Swapnil Sonawane
In that case you're going to want to put them into an array. See this thread I open with the developers on their forum. http://groups.google.com/group/mongodb-user/browse_thread/thread/eaf5a1e2a5817b61/868d8435bdaf57f0?q=#868d8435bdaf57f0
luckytaxi