List all documents from mongodb where the each document's one field has max value in spring boot

I have list of documents on mongodb like

Id, name, surname, salary. 

I want all documents would return which contains max salary. I know that i should aggregate the query in two step.

  1. First of all, I should find max value of salar field for all documents,
  2. and after then i should find all documents where salary equals maxValue.

But i cannot configure it neither JPA nor native query approach. How can i make it happen?



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)