Following is my MongoDB query which is
{$project:{
firstName: "$firstName",
lastName:"$lastName",
email:"$email",
company :"$organization.name",
RoleName :"$organization.roles.roleName",
matchingRole: { $eq: [ "$organization.roles.orgRoleId","$userOrgMap.roleId" ] }
}
},
{ $match: {matchingRole:true},{ $sort : { firstName : 1} }])
Following is my SpringData mongo API
aggregation = newAggregation(
project("firstName", "lastName", "email")
.and("organization.name").as("company")
.and("organization.roles.roleName").as("roleName")
I want to know how to use $eq in project aggregate using Spring API. I tried to put the match outside the project as shown below. But query is not fetching mew any records. So I used $eq to compare in the project and assign the result in a new project attribute and check for it outside the project pipeline.
{ $match: {$organization.roles.orgRoleId","$userOrgMap.roleId"}