-
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
enhancementNew feature or requestNew feature or request
Description
功能简述
通过Upsert实现数据表单个数据的改动,避免多次查询。
需求来源
有些情况下,只需要针对表中单个数据进行增加或减少,且对应的数据并未获取,此时便需要进行获取->修改->写入三个操作,十分不便。
因此,若支持通过Upsert针对该数据进行简单计算的修改,即可大大的增加整体效率。
功能参考(可选)
public void updateStats(long uid, StatsType type, int modify) {
if (modify == 0) return;
String tableName = DBTables.STATS.getTableName();
getSQLManager().executeSQL(
"INSERT INTO " + tableName + "(uid,type,value) " +
"VALUE(?,?,?) ON DUPLICATE KEY " +
"UPDATE value = value " + (modify > 0 ? "+" : "-") + "?" + " ",
new Object[]{uid, type.getID(), Math.abs(modify)}
);
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Status
Todo