替换
Replace
根据主键替换数据 注意:此方法没有开启事务。如需开启事务,见 Transaction
tbl1表结构: create table tbl1 ( f1 int primary key, f2 int, f3 int ) 例1:相当于 replace into tbl1(f1, f2, f3) values(1,2,3) 当存在 f1 = 1的数据时,相当于update tbl1 set f2=2,f3=3 where f1=1 当不存在f1= 1的数据时,相当于insert into tbl1(f1,f2,f3) values(1,2,3) let result = await Replace.replace(conn, { data: { f1: 1, f2: 2, f3: 3 }, table: 'tbl1' });
数据库连接对象
Promise对象
替换
Replace