Skip to content
代码片段 群组 项目
提交 37a2a79f 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic
浏览文件

Simplify query.

上级 ee685b24
No related branches found
No related tags found
无相关合并请求
......@@ -111,25 +111,11 @@ export function insertOrReplaceClusterState(
side,
enabled
) {
return DbApi.dbGet(
return DbApi.dbInsert(
db,
'SELECT COUNT(1) FROM ENDPOINT_TYPE_CLUSTER WHERE ENDPOINT_TYPE_REF = ? AND CLUSTER_REF = ? AND SIDE = ?',
[endpointTypeId, clusterRef, side]
).then((count) => {
if (count['COUNT(1)'] > 0) {
return DbApi.dbUpdate(
db,
'UPDATE ENDPOINT_TYPE_CLUSTER SET ENABLED = ? WHERE ENDPOINT_TYPE_REF = ? AND CLUSTER_REF = ? AND SIDE = ?',
[enabled, endpointTypeId, clusterRef, side]
)
} else {
return DbApi.dbInsert(
db,
'INSERT OR REPLACE INTO ENDPOINT_TYPE_CLUSTER ( ENDPOINT_TYPE_REF, CLUSTER_REF, SIDE, ENABLED ) VALUES ( ?, ?, ?, ?)',
[endpointTypeId, clusterRef, side, enabled]
)
}
})
'INSERT OR REPLACE INTO ENDPOINT_TYPE_CLUSTER ( ENDPOINT_TYPE_REF, CLUSTER_REF, SIDE, ENABLED ) VALUES ( ?, ?, ?, ?)',
[endpointTypeId, clusterRef, side, enabled]
)
}
/**
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册