Skip to main content
Module

x/kysely_deno_postgres_dialect/deps.ts>kysely.InsertResult

Kysely dialect for PostgreSQL using the deno-postgres client.
Latest
class kysely.InsertResult
Re-export
import { kysely } from "https://deno.land/x/kysely_deno_postgres_dialect@v0.27.1/deps.ts";
const { InsertResult } = kysely;

The result of an insert query.

If the table has an auto incrementing primary key insertId will hold the generated id on dialects that support it. For example PostgreSQL doesn't return the id by default and insertId is undefined. On PostgreSQL you need to use ReturningInterface.returning or ReturningInterface.returningAll to get out the inserted id.

numInsertedOrUpdatedRows holds the number of (actually) inserted rows. On MySQL, updated rows are counted twice when using on duplicate key update.

Examples

const result = await db
  .insertInto('person')
  .values(person)
  .executeTakeFirst()

console.log(result.insertId)

Constructors

new
InsertResult(insertId: bigint | undefined, numInsertedOrUpdatedRows: bigint | undefined)

Properties

readonly
insertId: bigint | undefined

The auto incrementing primary key of the inserted row.

This property can be undefined when the query contains an on conflict clause that makes the query succeed even when nothing gets inserted.

This property is always undefined on dialects like PostgreSQL that don't return the inserted id by default. On those dialects you need to use the ReturningInterface.returning | returning method.

readonly
numInsertedOrUpdatedRows: bigint | undefined

Affected rows count.