Is the MongoDB $push operator the way to add an embedded document?
I'm using MongoDB and Spring 3. I have the following domain object:
I want to add a From the documentation it seems like I need to use the | ||
4 | $push would be the correct way to add a new document to the array. You can see example code in this presentation (slide 22). The relevant line would be:
| ||
this presentation slide 22에서 mongoTemplate.getConverter().write()는 생략해도 된다.
중요한건 push()이다. --> http://docs.mongodb.org/manual/reference/operator/push/
'Framework & Platform > Spring' 카테고리의 다른 글
spring data - mongodb gridfs example (0) | 2013.07.20 |
---|---|
spring - Multiple File Upload Example (0) | 2013.07.17 |
spring - Array @ModelAttribute expansion in Spring MVC (0) | 2013.06.27 |
spring - 폼 태그(form tag) (0) | 2013.06.21 |
spring - @RequestMapping produces consumes (0) | 2013.06.19 |
mongoTemplate.updateFirst(Query.query(Criteria.where("username").is("username_1")), new Update().push("posts", newPostObject), User.class);
I think I got a bit confused because I was trying to user theUpdate
class statically - like i've seen done in many examples - and this did not allow thepush
method. – chrisjleu Jun 7 '12 at 20:50