0

How to get the single array element document with their objecID? For example the collection has an array but the array has own objectid and other properties.

Dc.Collection.FindOne(query); cant get the particular array document if i passed the array element objectid.

1 Answer 1

1

Does the array contain embedded documents, as in

{
    ObjectId : // some ID,
    ArrayField : [ 
        {
            ObjectId: // id,
            key: value
        },  
        {
            ObjectId: // id, 
            key: value2
        }
    ]
}

? In that case, you would want to query using dot notation, for instance:

findOne({"ArrayField.key" : value1 })

would match this document. Take a look at the fifth code example on this page:

http://www.mongodb.org/display/DOCS/Dot+Notation+(Reaching+into+Objects)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.