Inserts a row, then reads it back and returns it.
Folds the ubiquitous "insert then immediately SELECT the row" pattern into a single call. The row is re-read on the same shard using the routing key, matched by idColumn (defaulting to the value at values[idColumn], else key).
key
idColumn
values[idColumn]
Type of the returned row
Primary key used for shard routing and re-read
Target table name
Column to value map for the new row
Insert modifiers plus the idColumn used to re-read (default id)
id
The created row, or null if it could not be read back
null
1.2.4
const created = await insertReturning('user-123', 'users', { id: 'user-123', username: 'ada' }); Copy
const created = await insertReturning('user-123', 'users', { id: 'user-123', username: 'ada' });
Inserts a row, then reads it back and returns it.
Folds the ubiquitous "insert then immediately SELECT the row" pattern into a single call. The row is re-read on the same shard using the routing
key, matched byidColumn(defaulting to the value atvalues[idColumn], elsekey).