// 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);
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);
本文详细介绍了使用Datastore进行数据库更新操作的方法,包括如何增加或减少特定字段的数值。通过四个具体的示例,展示了如何创建更新操作并执行增减操作。
14万+

被折叠的 条评论
为什么被折叠?



