import { entityKind } from "../../entity.cjs"; import type { GelDialect } from "../dialect.cjs"; import type { IndexColumn } from "../indexes.cjs"; import type { GelPreparedQuery, GelQueryResultHKT, GelQueryResultKind, GelSession, PreparedQueryConfig } from "../session.cjs"; import type { GelTable, TableConfig } from "../table.cjs"; import type { TypedQueryBuilder } from "../../query-builders/query-builder.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, SQLWrapper } from "../../sql/sql.cjs"; import { Param, SQL } from "../../sql/sql.cjs"; import type { Subquery } from "../../subquery.cjs"; import type { InferInsertModel } from "../../table.cjs"; import type { AnyGelColumn } from "../columns/common.cjs"; import { QueryBuilder } from "./query-builder.cjs"; import type { SelectedFieldsFlat, SelectedFieldsOrdered } from "./select.types.cjs"; import type { GelUpdateSetSource } from "./update.cjs"; export interface GelInsertConfig { table: TTable; values: Record[] | GelInsertSelectQueryBuilder | SQL; withList?: Subquery[]; onConflict?: SQL; returning?: SelectedFieldsOrdered; select?: boolean; overridingSystemValue_?: boolean; } export type GelInsertValue, OverrideT extends boolean = false> = { [Key in keyof InferInsertModel]: InferInsertModel[Key] | SQL | Placeholder; } & {}; export type GelInsertSelectQueryBuilder = TypedQueryBuilder<{ [K in keyof TTable['$inferInsert']]: AnyGelColumn | SQL | SQL.Aliased | TTable['$inferInsert'][K]; }>; export declare class GelInsertBuilder { private table; private session; private dialect; private withList?; private overridingSystemValue_?; static readonly [entityKind]: string; constructor(table: TTable, session: GelSession, dialect: GelDialect, withList?: Subquery[] | undefined, overridingSystemValue_?: boolean | undefined); private authToken?; overridingSystemValue(): Omit, 'overridingSystemValue'>; values(value: GelInsertValue): GelInsertBase; values(values: GelInsertValue[]): GelInsertBase; select(selectQuery: (qb: QueryBuilder) => GelInsertSelectQueryBuilder): GelInsertBase; select(selectQuery: (qb: QueryBuilder) => SQL): GelInsertBase; select(selectQuery: SQL): GelInsertBase; select(selectQuery: GelInsertSelectQueryBuilder): GelInsertBase; } export type GelInsertWithout = TDynamic extends true ? T : Omit, T['_']['excludedMethods'] | K>; export type GelInsertReturning = GelInsertBase, TDynamic, T['_']['excludedMethods']>; export type GelInsertReturningAll = GelInsertBase; export interface GelInsertOnConflictDoUpdateConfig { target: IndexColumn | IndexColumn[]; /** @deprecated use either `targetWhere` or `setWhere` */ where?: SQL; targetWhere?: SQL; setWhere?: SQL; set: GelUpdateSetSource; } export type GelInsertPrepare = GelPreparedQuery : T['_']['returning'][]; }>; export type GelInsertDynamic = GelInsert; export type AnyGelInsert = GelInsertBase; export type GelInsert | undefined = Record | undefined> = GelInsertBase; export interface GelInsertBase | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise : TReturning[]>, RunnableQuery : TReturning[], 'gel'>, SQLWrapper { readonly _: { readonly dialect: 'gel'; readonly table: TTable; readonly queryResult: TQueryResult; readonly returning: TReturning; readonly dynamic: TDynamic; readonly excludedMethods: TExcludedMethods; readonly result: TReturning extends undefined ? GelQueryResultKind : TReturning[]; }; } export declare class GelInsertBase | undefined = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise : TReturning[]> implements RunnableQuery : TReturning[], 'gel'>, SQLWrapper { private session; private dialect; static readonly [entityKind]: string; private config; constructor(table: TTable, values: GelInsertConfig['values'], session: GelSession, dialect: GelDialect, withList?: Subquery[], select?: boolean, overridingSystemValue_?: boolean); /** * Adds a `returning` clause to the query. * * Calling this method will return the specified fields of the inserted rows. If no fields are specified, all fields will be returned. * * See docs: {@link https://orm.drizzle.team/docs/insert#insert-returning} * * @example * ```ts * // Insert one row and return all fields * const insertedCar: Car[] = await db.insert(cars) * .values({ brand: 'BMW' }) * .returning(); * * // Insert one row and return only the id * const insertedCarId: { id: number }[] = await db.insert(cars) * .values({ brand: 'BMW' }) * .returning({ id: cars.id }); * ``` */ returning(): GelInsertWithout, TDynamic, 'returning'>; returning(fields: TSelectedFields): GelInsertWithout, TDynamic, 'returning'>; toSQL(): Query; prepare(name: string): GelInsertPrepare; execute: ReturnType['execute']; $dynamic(): GelInsertDynamic; }