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

試著忘記壹切 提交于 2020-05-23 23:53:55

问题


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


回答1:


I am sure you got the answer by far now, still updating it to help other folks.

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);


来源:https://stackoverflow.com/questions/38973231/how-to-update-particular-field-in-mongo-db-by-using-mongorepository-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!