SpringData MongoDB Using Projection

This is their way by which I can use the mongodb projection function to extract selected fields from a document.

Even after searching all day on the Internet, I couldn’t find any hint.

+4
source share
1 answer

Here is the relevant section of documents related to repositories. Also in the section when requesting documents contains a brief mention of this.

When using, MongoOperationsyou can use an instance Queryto limit the result for certain fields:

Query query = Query.query(Criteria.where("lastname").eq("…"));
// Configure the field spec you want to use for this query
query.fields().include(…).slice(…);

DATAMONGO-839, , JavaDoc Query.

+6

Source: https://habr.com/ru/post/1524525/


All Articles