How to add/remove elements from a MongoDB list using spring data? -
i using spring data talk mongo (although know there few downsides on mongo driver advanced use cases). application has mongodb document 1 of elements being list. want add/delete specific elements list in document. can please tell me if , how spring data supports (considering basic operation)?
i did quite web search didn't seem land on concrete.
any appreciable.
update 1: sample document:
{ id: 123, arr: [ 1,2,3,4]} and after update
{ id: 123, arr: [ 1,2,3]} or { id: 123, arr: [ 1,2,3,4,5]}
i'm looking @ unit tests , looks can use mongo $pull , $push methods using update class.
you can see tutorial here:
http://www.dineshonjava.com/2013/01/spring-data-mongodb-update-document.html#.vvexp3uvhbc
so you'd doing like:
update().pull("arr", 4); update().push("arr", 5);
Comments
Post a Comment