Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update particular field in mongo db by using MongoRepository Interface?

How to update a particular field in mongo db collection by using MongoRepository Interface in spring?

like image 780
Anil Avatar asked Aug 16 '16 11:08

Anil


1 Answers

You can update specific field by below code:

Query query1 = new Query(Criteria.where("id").is("123"));
Update update1 = new Update();
update1.set("available", false);
mongoTemplate.updateFirst(query1, update1, Customer.class);
like image 131
Ravi Mandli Avatar answered Oct 14 '22 20:10

Ravi Mandli