Framework & Platform/Spring

spring data - mongodb tip

linuxism 2014. 4. 4. 11:43


* 숫자 증가

Update u = new Update();

u.inc("element", 1);

mongoTemplate.updateFirst(query(where("id").is(id)), u, domain.class);


* update in array(list)

Update u = new Update();

u.inc("array.$.value", 1);

mongoTemplate.updateFirst(query(where("id").is(id).and("array.key").is(key)), u, domain.class);