db.users.aggregate(
{$match :
{"_id" : ObjectId("50f69176904e1d66affec20d")}
},
{$unwind : "$connections"},
{$match :
{$or : [
{"connections.users" : {$exists : false}},
{"connections.users.id" : "50f651b8b58bba7fbec2f223"}
]}},
{$group : {_id : "$connections.group"}}
)
在这里,我找到了特定用户所在的组名。我在 mongodb shell 中得到了正确的结果。现在我必须在锂框架中使用它。请帮我执行命令。有关集合结构,请参阅此链接: http: //pastebin.com/P8uMw9cj