import { entityKind } from "../../entity.cjs"; import type { SelectResultFields } from "../../query-builders/select.types.cjs"; import { QueryPromise } from "../../query-promise.cjs"; import type { RunnableQuery } from "../../runnable-query.cjs"; import type { Placeholder, Query, SQL, SQLWrapper } from "../../sql/sql.cjs"; import type { SQLiteDialect } from "../dialect.cjs"; import type { SQLitePreparedQuery, SQLiteSession } from "../session.cjs"; import { SQLiteTable } from "../table.cjs"; import type { Subquery } from "../../subquery.cjs"; import { type DrizzleTypeError, type ValueOrArray } from "../../utils.cjs"; import type { SQLiteColumn } from "../columns/common.cjs"; import type { SelectedFieldsFlat, SelectedFieldsOrdered } from "./select.types.cjs"; export type SQLiteDeleteWithout = TDynamic extends true ? T : Omit, T['_']['excludedMethods'] | K>; export type SQLiteDelete | undefined = undefined> = SQLiteDeleteBase; export interface SQLiteDeleteConfig { where?: SQL | undefined; limit?: number | Placeholder; orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[]; table: SQLiteTable; returning?: SelectedFieldsOrdered; withList?: Subquery[]; } export type SQLiteDeleteReturningAll = SQLiteDeleteWithout, TDynamic, 'returning'>; export type SQLiteDeleteReturning = SQLiteDeleteWithout, T['_']['dynamic'], T['_']['excludedMethods']>, TDynamic, 'returning'>; export type SQLiteDeleteExecute = T['_']['returning'] extends undefined ? T['_']['runResult'] : T['_']['returning'][]; export type SQLiteDeletePrepare = SQLitePreparedQuery<{ type: T['_']['resultType']; run: T['_']['runResult']; all: T['_']['returning'] extends undefined ? DrizzleTypeError<'.all() cannot be used without .returning()'> : T['_']['returning'][]; get: T['_']['returning'] extends undefined ? DrizzleTypeError<'.get() cannot be used without .returning()'> : T['_']['returning'] | undefined; values: T['_']['returning'] extends undefined ? DrizzleTypeError<'.values() cannot be used without .returning()'> : any[][]; execute: SQLiteDeleteExecute; }>; export type SQLiteDeleteDynamic = SQLiteDelete; export type AnySQLiteDeleteBase = SQLiteDeleteBase; export interface SQLiteDeleteBase | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise, RunnableQuery, SQLWrapper { readonly _: { dialect: 'sqlite'; readonly table: TTable; readonly resultType: TResultType; readonly runResult: TRunResult; readonly returning: TReturning; readonly dynamic: TDynamic; readonly excludedMethods: TExcludedMethods; readonly result: TReturning extends undefined ? TRunResult : TReturning[]; }; } export declare class SQLiteDeleteBase | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise implements RunnableQuery, SQLWrapper { private table; private session; private dialect; static readonly [entityKind]: string; constructor(table: TTable, session: SQLiteSession, dialect: SQLiteDialect, withList?: Subquery[]); /** * Adds a `where` clause to the query. * * Calling this method will delete only those rows that fulfill a specified condition. * * See docs: {@link https://orm.drizzle.team/docs/delete} * * @param where the `where` clause. * * @example * You can use conditional operators and `sql function` to filter the rows to be deleted. * * ```ts * // Delete all cars with green color * db.delete(cars).where(eq(cars.color, 'green')); * // or * db.delete(cars).where(sql`${cars.color} = 'green'`) * ``` * * You can logically combine conditional operators with `and()` and `or()` operators: * * ```ts * // Delete all BMW cars with a green color * db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW'))); * * // Delete all cars with the green or blue color * db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue'))); * ``` */ where(where: SQL | undefined): SQLiteDeleteWithout; orderBy(builder: (deleteTable: TTable) => ValueOrArray): SQLiteDeleteWithout; orderBy(...columns: (SQLiteColumn | SQL | SQL.Aliased)[]): SQLiteDeleteWithout; limit(limit: number | Placeholder): SQLiteDeleteWithout; /** * Adds a `returning` clause to the query. * * Calling this method will return the specified fields of the deleted rows. If no fields are specified, all fields will be returned. * * See docs: {@link https://orm.drizzle.team/docs/delete#delete-with-return} * * @example * ```ts * // Delete all cars with the green color and return all fields * const deletedCars: Car[] = await db.delete(cars) * .where(eq(cars.color, 'green')) * .returning(); * * // Delete all cars with the green color and return only their id and brand fields * const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars) * .where(eq(cars.color, 'green')) * .returning({ id: cars.id, brand: cars.brand }); * ``` */ returning(): SQLiteDeleteReturningAll; returning(fields: TSelectedFields): SQLiteDeleteReturning; toSQL(): Query; prepare(): SQLiteDeletePrepare; run: ReturnType['run']; all: ReturnType['all']; get: ReturnType['get']; values: ReturnType['values']; execute(placeholderValues?: Record): Promise>; $dynamic(): SQLiteDeleteDynamic; }