Last Updated: 3/10/2026
Interface ReturningInterface<DB, TB, O>
Type Parameters
Hierarchy (View Summary)
Implemented by
Index
Methods
Methods
returning
Allows you to return data from modified rows.
On supported databases like PostgreSQL, this method can be chained to
insert, update, delete and merge queries to return data.
insert
update
delete
merge
Note that on SQLite you need to give aliases for the expressions to avoid
this bug in SQLite.
For example .returning('id as id').
.returning('id as id')
Also see the returningAll method.
Examples
Return one column:
const { id } = await db .insertInto('person') .values({ first_name: 'Jennifer', last_name: 'Aniston' }) .returning('id') .executeTakeFirstOrThrow()
Return multiple columns:
const { id, last_name } = await db .insertInto('person') .values({ first_name: 'Jennifer', last_name: 'Aniston' }) .returning(['id', 'last_name']) .executeTakeFirstOrThrow()
Return arbitrary expressions:
`import { sql } from ‘kysely’
const { id, full_name, first_pet_id } = await db
.insertInto(‘person’)
.values({
first_name: ‘Jennifer’,
last_name: ‘Aniston’
})
.returning((eb) => [
‘id as id’,
sqlconcat(first_name, ' ', last_name).as(‘full_name’),
eb.selectFrom(‘pet’).select(‘pet.id’).limit(1).as(‘first_pet_id’)
])
.executeTakeFirstOrThrow()`
Type Parameters
Parameters
Returns ReturningInterface<DB, TB, ReturningRow<DB, TB, O, SE>>
Type Parameters
Parameters
Returns ReturningInterface<DB, TB, ReturningCallbackRow<DB, TB, O, CB>>
Type Parameters
Parameters
Returns ReturningInterface<DB, TB, ReturningRow<DB, TB, O, SE>>
returningAll
Adds a returning * to an insert/update/delete/merge query on databases
that support returning such as PostgreSQL.
returning *
returning
Also see the returning method.
Returns ReturningInterface<DB, TB, Selectable<DB[TB]>>
Settings
On This Page
Generated using TypeDoc