2
如何優化此代碼? 我不想打電話2次...有沒有可能比這更好的查詢?Knexjs如果不存在insert其他更新
return self.db.clientDevices.where(device).then(function (rows) {
if (rows.length != 1) {
device.key = value;
self.db.clientDevices.insert(device).then();
} else {
self.db.clientDevices.where(device).update(device).then();
}
});