在嵌套文档中查询特定对象是否可能?以下是一个示例,
Collection : Threads
{
Documents : Messages
{
threadId = 1
messages = [
{
user = amy
date = 01/01/2012
content = hey
},
{
user = bell
date = 01/01/2012
content = hey
},
{
user = bell
date = 01/02/2012
content = whats up
}
]
},
{
threadId = 2
messages = [
{
user = courtney
date = 01/03/2012
content = first!
}
]
}
}
我希望查询语句能够显示如下内容:{ threadId : 1, 'messages.date' : { $gt : 01/01/2012 } }, { fields : { messages : 1 } }
。但实际上,它会返回所有文档中的消息,而我想要的结果只是这个:
messages = [
{
user = bell
date = 01/02/2012
content = whats up
}
]