Do db.collection.replaceOne by spring data mongo

戏子无情 提交于 2020-05-17 14:42:47

问题


I want to replace whole document in mongo collection in one update instead of "query and update".

It seems the db.collection.replaceOne can do this job, but I can't find any api in the MongoOperations.


回答1:


Just call save() on MongoTemplate which will invoke replaceOne with UpdateOptions().upsert(true).



来源:https://stackoverflow.com/questions/49749209/do-db-collection-replaceone-by-spring-data-mongo

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