0

my mongo object will be like this

{
    "colID" : "1",
    "title" : "title",
    "desciption : "description",
    "array" : [
        { "identifier" : "1", "title" : "test1"},
        { "identifier" : "2", "title" : "test2"},
    ]
}

Input is : colID is 1 and identifier is 2. Now I would like to get the following response

{
    "colID" : "1",
    "title" : "title",
    "desciption : "description",
    "array" : [
        { "identifier" : "2", "title" : "test2"}
    ]
}

Please help I am very new to mongoDB. thanks in advance.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317

1 Answers1

0

Use the $elemMatch operator.

Look the MongoDB documentation:

http://docs.mongodb.org/manual/reference/operator/projection/elemMatch/