I am trying to INSERT OR REPLACE for both updates. This works if I pass r_id to the query but I want to replace only if r_id is passed, or insert if r_id is empty. When I do this I'm getting a type mismatch error. r_id is the primary key, an integer.
INSERT OR REPLACE INTO ${tableNames[1].name} (r_id,r_from_ac_type_id,r_to_ac_type_id,r_date,r_amount,r_note) values` +
recordItems
.map(
i =>
`('${i.r_id}','${i.r_from_ac_type_id}','${i.r_to_ac_type_id}', '${i.r_date}','${i.r_amount}','${i.r_note}')`,
)
.join(',')