Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/kysely_postgrs_js_dialect/mod.ts>kysely.InferResult

Kysely dialect for PostgreSQL using the Postgres.js client.
Go to Latest
type alias kysely.InferResult
import { type kysely } from "https://deno.land/x/kysely_postgrs_js_dialect@v0.27.4/mod.ts";
const { InferResult } = kysely;

A helper type that allows inferring a select/insert/update/delete query's result type from a query builder or compiled query.

Examples

Infer a query builder's result type:

import { InferResult } from 'kysely'

const query = db
  .selectFrom('person')
  .innerJoin('pet', 'pet.owner_id', 'person.id')
  .select(['person.first_name', 'pet.name'])

type QueryResult = InferResult<typeof query> // { first_name: string; name: string; }[]

Infer a compiled query's result type:

import { InferResult } from 'kysely'

const compiledQuery = db
  .insertInto('person')
  .values({
    first_name: 'Foo',
    last_name: 'Barson',
    gender: 'other',
    age: 15,
  })
  .returningAll()
  .compile()

type QueryResult = InferResult<typeof compiledQuery> // Selectable<Person>[]
definition: C extends Compilable<infer O> ? ResolveResult<O> : C extends CompiledQuery<infer O> ? ResolveResult<O> : never