Simple INSERT
Insert a new entity into a table using the db.insert
driver method:
db.insert(new Contact({ name:'John', email:'[email protected]', age:27 }))
db.insert(new Product({ sku:'WIDGET', name:'Acme Widget', cost:10 }))
INSERT Multiple Rows
Insert multiple entities into a table using the db.insertAll
driver method:
db.insertAll([
new Contact({ name:'John', email:'[email protected]', age:27 }),
new Contact({ name:'Jane', email:'[email protected]', age:31 })
])
INSERT Expression
When the full flexibility of SQL is needed, you can execute a SQL fragment directly:
const { name, age } = { name:'John', age:27 }
db.run`INSERT INTO Contact (name,age) VALUES (${name},${age})`