我尝试过,但是我无法使查询计数,例如 假设我们有一个像这样的文件:
{
"_id" : ObjectId("24926523r3423423423423rr"),
"name" : "My super team",
"stadium" : "Capital",
"players" : [
{
"name" : "PlayerName1",
"number" : "1",
"country" : "BRA"
},
{
"name" : "PlayerName2",
"number" : "2",
"country" : "FRA"
},
{
"name" : "PlayerName3",
"number" : "3",
"country" : "BRA"
},
{
"name" : "PlayerName4",
"number" : "4",
"country" : "ARG"
},
{
"name" : "PlayerName5",
"number" : "5",
"country" : "GER"
},
{
"name" : "PlayerName6",
"number" : "6",
"country" : "BRA"
},
]
}
问题是如何计算“我的超级团队”团队中的所有“ BRA”球员(我有很多团队。任何想法?我尝试将$ size和聚合组合在一起,但失败了,或者更好如果您有技巧如何使用Morphia处理该查询?