插入数据
Insert
插入一条数据 注意:插入字段会根据table表中实际字段进行匹配,只有实际存在的字段才会插入。见下面例子。 注意:此方法没有开启事务。如需开启事务,见 Transaction
tbl1表结构: create table tbl1 ( f1 int, f2 int, f3 int ) 例1,以下相当于SQL: insert into tbl1(f1, f2, f3) values(1, 2, 3); let result = await Insert.insert(conn, { data: { f1: 1, f2: 2, f3: 3, f4: 4 }, // f4 不是字段,插入成功 table: 'tbl1' }); 例2,以下相当于SQL: insert into tbl1(f1, f2) values(1, 2); let result = await Insert.insert(conn, { data: { f1: 1, f2: 2 }, // 少一个字段f3,插入成功 table: 'tbl1' });
数据库连接对象
Promise对象
插入数据
Insert