以下是MongoDB查询。我坚持为组和项目找到合适的Spring API等价物。
db.users.aggregate([
{ $lookup: { from: "organizations", localField: "orgId",
foreignField: "_id", as:"organization" } },
{$unwind: "$organization"},
{ $group: { _id: "$userOrgMap.orgId", userCount: { $sum: 1 }, name: { "$first": "$organization.name"}, status: { "$first": "$organization.status"}, },
{$project:{ _id:1, name:1, status:1, userCount :1 } }, { $sort:{userCount:-1} } ]);
需要帮助来提供有关需要用于$ group和$ project管道的Spring Data MongoDB API的详细信息