import Insert from '@stackpress/inquire/Insert';
Most code uses it through engine.insert(table).
Example
await engine.insert('users').values([
{ email: '[email protected]', name: 'Ada' },
{ email: '[email protected]', name: 'Grace' }
]);
Methods
values(values)
Set the rows to insert.
| Parameter | Type | |
|---|---|---|
values | `Record<string, Value> \ | Record<string, Value>[]` |
returning(columns?)
Request returned columns where the dialect supports it.
const rows = await engine.insert('users')
.values({ email: '[email protected]' })
.returning(['id', 'email']);
build()
Return the internal insert state.
query(dialect?)
Return one QueryObject.
then(resolve, reject?)
Execute the query through the attached engine.
Returns
When awaited, Insert<R> resolves to R[].
For drivers without RETURNING, you will often get an empty array and inspect connection.lastId instead.