我有以下数据:
/* 1 */
{
"_id" : 1,
"FirstName" : "John",
"LastName" : "Doe",
"Test" : [{
"TestId" : ObjectId("5046109daedabb0cf8800f3f"),
"DateTaken" : ISODate("2012-09-10T15:46:32.866Z")
}, {
"TestId" : ObjectId("506e0928aedabb087c4ec9d1"),
"DateTaken" : ISODate("2011-06-26T18:05:52.625Z"),
"Responses" : [{
"AnswerId" : "506e0928aedabb087c4ec98c",
"QuestionId" : ObjectId("506e0928aedabb087c4ec98b"),
"ResponseDate" : ISODate("2011-06-26T04:00:00Z")
}]
}]
}
/* 2 */
{
"_id" : 2,
"FirstName" : "Jane",
"LastName" : "Doe",
"TestHistory" : [{
"TestId" : ObjectId("506e0928aedabb087c4ec9d1"),
"DateTaken" : ISODate("2011-06-26T18:05:52.625Z"),
"Responses" : [{
"AnswerId" : "506e0928aedabb087c4ec98c",
"QuestionId" : ObjectId("506e0928aedabb087c4ec98b"),
"ResponseDate" : ISODate("2011-06-26T04:00:00Z")
}]
}]
}
我正在尝试编写一个查询,该查询返回存在没有响应的测试的所有实例。我尝试了以下查询:
- { "Test.Responses": { $exists: false } }
- { $and: [ { Test: { $exits: true } }, { "Test.Responses": { $exists: false} } ] }
两者都返回 0 结果。我错过了什么?