我有一个类似json的数据
{
"organizationId" : "org1",
"userId" : "user1",
"transactionNo" : "342"
},
{
"organizationId" : "org1",
"userId" : "user1",
"transactionNo" : "343"
},
{
"organizationId" : "org1",
"userId" : "user1",
"transactionNo" : "344"
},
{
"organizationId" : "org1",
"userId" : "user2",
"transactionNo" : "324"
},
{
"organizationId" : "org1",
"userId" : "user2",
"transactionNo" : "325"
},
{
"organizationId" : "org1",
"userId" : "user3",
"transactionNo" : "324"
},
{
"organizationId" : "org2",
"userId" : "user1",
"transactionNo" : "324"
},
{
"organizationId" : "org2",
"userId" : "user2",
"transactionNo" : "324"
},
{
"organizationId" : "org3",
"userId" : "user1",
"transactionNo" : "324"
}
因此,我拥有所有这些记录,其中一个组织将有多个用户,而一个用户正在执行多个活动。 我的要求是提供“ organisationId”,并获取该组织的用户数。对于此示例,如果我提供“ org1”,则应获得“ 3”
我已经在Spring数据mongo存储库中尝试了方法“ getDistinctUserIdByOrganisationId(String OrganisationId)”。但是它不起作用。在@Query()中写什么? 如何使用其他选项解决?我是蒙哥的新手。我以前在mysql上工作过。