Spring data MongoDB adding arrays to an existing document

安稳与你 提交于 2019-12-04 12:15:28

I don't think you can do it in that way. Previously i had the same situation, and I tried the following

1.org.springframework.core.convert.converter.Converter even I have managed to manipulate the DBObject but functions like $push or $set(wrapping them under key) does not work over there.

2.AbstractMongoEventListener by overriding onBeforeSave but Object manipulation was not taking place during save.

However you can try altering the mentioned

you can try override MongoRepository save method, It would better if someone point to the right direction. Otherwise for my scenario I had to create Custom repository(To update and delete document) which is working parallel with MongoRepository (for Insert and retrieve data/document), but I believe thats an ugly workaround. There has to be a cleaner way to do it.

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