// 1.'xx'属性增长一
ops = datastore.createUpdateOperations(Hotel.class).inc("xx");
datastore.update(updateQuery, ops);
// 2.'xx'属性值增长4
ops = datastore.createUpdateOperations(Hotel.class).inc("xx", 4);
datastore.update(updateQuery, ops);
// 3.'xx'属性值减少1
ops = datastore.createUpdateOperations(Hotel.class).dec("xx"); // 和 .inc("xx", -1) 相同
datastore.update(updateQuery, ops);
// 4.'xx'属性值减少4
ops = datastore.createUpdateOperations(Hotel.class).inc("xx", -4);
datastore.update(updateQuery, ops);
mongodb inc/dec
猜你喜欢
转载自dengshengyx.iteye.com/blog/1736695
今日推荐
周排行