How to find and search documents in Spring Data MongoDb [ Spring Boot ]

preview_player
Показать описание
spring data mongodb build query | mongorepository spring boot example | mongotemplate spring boot example | mongotemplate criteria query | Spring boot find query mongodb

Hello and namaste everyone,

Today we are talking about different ways of building the queries in Spring Data MongoDb. We're going to be looking at querying documents with Query and Criteria classes, auto-generated query methods, JSON queries.
One way is to use the common type of query that Spring Data usually provides – auto-generated queries out of method names.
The second way is if we can't represent a query with the help of a method name, or criteria, we can do something more low level – use the @Query annotation. we can specify a raw query – as a Mongo JSON query string.
The third way is by making use of the Query and Criteria classes – which very closely mirror native operators.

Choose your way of doing it, according to your use case and time.

Рекомендации по теме
Комментарии
Автор

Hi, Do you have git repo. so that I can pull these code

in_time
Автор

I would like to understand how do I compare two fields in the document. Has anyone ever needed to do this type of comparison? I'm using the criteria.



== this.campoD"));



Query query = new Query();
List<Criteria> criteria = new ArrayList<>();



== this.campoD")); // <---- How do you compare two fields???

query.addCriteria(new
return query;

acessosan
visit shbcf.ru