我的mongo对象将是这样的
{
"colID" : "1",
"title" : "title",
"desciption : "description",
"array" : [
{ "identifier" : "1", "title" : "test1"},
{ "identifier" : "2", "title" : "test2"},
]
}
输入为:colID为1,标识符为2.现在我想得到以下响应
{
"colID" : "1",
"title" : "title",
"desciption : "description",
"array" : [
{ "identifier" : "2", "title" : "test2"}
]
}
请帮助我对mongoDB很新。提前谢谢。
答案 0 :(得分:0)
使用$ elemMatch运算符。
查看MongoDB文档:
http://docs.mongodb.org/manual/reference/operator/projection/elemMatch/