【发布时间】:2015-10-14 09:50:48
【问题描述】:
Mongo Document
{"objects":
{ 1 : { Type: "A"},
{ 2 : { Type: "B"},
{ 3 : { Type: "C"},
{ 4 : { Type: "A"}
}
Desired result:
{
1 : { Type : "A"},
4 : { Type : "A"}
}
如何查询上面的Mongo Document得到上面的Desired result?
【问题讨论】:
-
也许这篇文章会对return-only-specific-fields-from-projection-array-sub-document 有所帮助。但是如果允许的话将对象的值定义为对象数组不是更好吗,因为mongodb对Array documents projection有很好的支持
标签: mongodb mongoose mongodb-query mongodb-java nosql