Reputation: 768
I am to run following query for my micro service through Mongo template.
find({"accId": 1234}, {"_id":0}).
I am using Query and Criteria libraries. I have tried various combinations of the addCriteria but I am unable to reach the desired query.
Any inputs or guidance here ?
Upvotes: 0
Views: 844
Reputation: 13093
Try this:
@Autowired
private MongoTemplate mongoTemplate;
...
Query q = new Query(Criteria.where("accId").is(1234));
q.fields().exclude("_id");
List<YourClass> result = mongoTemplate.find(q, YourClass.class);
Upvotes: 2