is it possible to exclude fields of nested Documents in Spring Data MongoDB?.
If tried it with
query.fields().exclude("user.password");
but that ends with the hole user document be excluded.
is it possible to exclude fields of nested Documents in Spring Data MongoDB?.
If tried it with
query.fields().exclude("user.password");
but that ends with the hole user document be excluded.
You can achieve that using Aggregation and ProjectOperation.
ProjectionOperation projectionOperation = project().andExclude("user.password");
mongoTemplate.aggregate(Aggregation.newAggregation(projectionOperation);