我试图找出如何最好地找到包含名为statusHistory的数组中的子文档数组的文档,其中存在以下两种情况之一:
在此示例中,查询应仅返回以下匹配单元的单元文档:
在此示例中,以下文档不匹配:
{
"unit":"100",
"statusHistory":[
{
"action":"Move-In",
"deletedOn":ISODate("2017-02-08T18:27:52.938+0000")
},
{
"action":"Assignment"
}
]
},
{
"unit":"200",
"statusHistory":[
{
"action":"Move-In",
"deletedOn":ISODate("2017-06-08T21:27:52.938+0000")
},
{
"action":"Assignment"
"deletedOn":ISODate("2017-05-08T21:27:52.938+0000")
}
]
},
{
"unit":"300",
"statusHistory":[
{
"action":"Move-In",
"deletedOn":ISODate("2017-06-08T21:27:52.938+0000")
},
{
"action":"Assignment"
"deletedOn":ISODate("2017-05-08T21:27:52.938+0000")
},
{
"action":"Move-In",
"deletedOn":ISODate("2017-04-08T21:27:52.938+0000")
},
{
"action":"Assignment"
"deletedOn":ISODate("2017-03-08T21:27:52.938+0000")
}
]
},
{
"unit":"400",
"statusHistory":[]
},
{
"unit":"500",
"statusHistory":[]
},
{
"unit":"600",
"statusHistory":[
{
"action":"Move-In",
},
{
"action":"Assignment"
}
]
}