How to code with Spring data MongoDB for db.test.u

2019-08-28 17:27发布

问题:

From console, I can operate as db.test.update({name:'abc'}, {$pull: {'child': {'age':10}}}).

How to code with spring-data-mongodb in Java for this instruction? I got mongoTemplate. I know I need to invoke Update.pull(). But I don't know the details.

Thanks for your response.

回答1:

update.pull("child", new BasicDBObject("age", 10));

mongoOperation.updateMulti(query, update, collectionName);