是否可以在嵌套文档中查询特定对象?这是一个例子,
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
}
]