This content is not available in your language yet.
Short and simple examples of how to write delete queries.
import { Generated } from 'kysely' declare global { interface DB { person: PersonTable pet: PetTable } interface PersonTable { id: Generated<string> first_name: string last_name: string | null created_at: Generated<Date> age: number } interface PetTable { id: Generated<string> name: string owner_id: string species: 'cat' | 'dog' is_favorite: boolean }}
const result = await db .deleteFrom('person') .where('person.id', '=', '1') .executeTakeFirst() console.log(result.numDeletedRows)
DELETE FROM "person"WHERE "person"."id" = $1 -- Parameters-- [1] 1
DELETE FROM `person`WHERE `person`.`id` = ? -- Parameters-- [1] 1
DELETE FROM "person"WHERE "person"."id" = ? -- Parameters-- [1] 1