I have MongoDB Collection of documents as below format.
`
{
"_id" : "...",
"parameters" : [
{
"name" : "ApplicationId",
"value" :" App1"
},
{
"name" : "policyId",
"value" :" pol1"
},
{
"name" : "primaryCustomerId",
"value" :" cust1"
},
{
"name" : "brokerId",
"value" :" broker1"
},
...
],
"createDateTime": "2020-01-14T18:32:19Z",
"updateDateTime": "2020-10-05T00:54:17Z",
"createdBy": "54420583-5ece-4261-a616-12f8c27e220d",
"updatedBy": "54420583-5ece-4261-a616-12f8c27e220d",
...
}
How can I write a query to find collections which will do search using "parameters" is having element name = brokerId and value = broker1 and it will sort on value of element(parameters.value) using parameters.name =primaryCustomerId using reactiveMongoTemplate?
I am trying aggregation and projection for the same. But somehow I am unable to add field(which we can user later for sorting) in aggregation using reactiveMongoTemplate.