Reputation: 364
I am have very simple requirement, where through MongoTemplate I am trying to filter and provide output. While providing output i need to change the column names through alias. ''' Query query = new Query().allowDiskUse(true); query.addCriteria(Criteria.where("column1").is("yes") ..... Now through query.fields().include() i can do projection, but how can give different name to resulting column like alias '''
Upvotes: 0
Views: 27
Reputation: 15235
Not sure If I'm understood correctly but I think you can use a simple aggregation pipeline.
Check this documentation to use projection.
So I think you can try something like this (not tested):
Aggregation agg = Aggregation.newAggregation(
match(Criteria.where("column1").is("yes")),
project().and("column1").as("your alias here")
);
Upvotes: 0