0

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.

user2663484
  • 11
  • 1
  • 4

1 Answers1

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

mongoOperation.updateMulti(query, update, collectionName);
laalto
  • 150,114
  • 66
  • 286
  • 303
  • BasicDBObject is not imported in spring-data-mongodb maven dependency. Right? Are you using the same maven dependency? – user2663484 Aug 09 '13 at 07:25
  • 1
    BasicDBObject should be available via spring data, it's from the underlying Java Driver that spring data uses. – Trisha Aug 11 '13 at 09:52