【发布时间】:2017-12-04 05:06:48
【问题描述】:
{
"_id" : "R9zbu8oTWwgxT5eCR",
"practiceSetup" : {
"operatoriesSettings" : [
{
"name" : "Operatory 1",
"description" : "Room 1",
"status" : true
},
{
"name" : "Operatory 2",
"description" : "Room B",
"status" : true
}
],
}
我正在尝试查找名称为“Operatory 1”的对象,并且只返回该对象。
这是我尝试过的,
Practice.findOne({ _id: 'R9zbu8oTWwgxT5eCR' }, { "$elemMatch": { "practiceSetup.operatoriesSettings": { "name": "Operatory 1" } } } );
但是,这将返回整个文档,而不是那个特定的对象,不确定我在这里做错了什么。
【问题讨论】:
-
我想我刚刚回答了一个非常相似的问题:stackoverflow.com/questions/47624171/…