GelInsertBase Class — drizzle-orm Architecture
Architecture documentation for the GelInsertBase class in insert.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 47f802c3_39d4_8a05_ef43_b3ba205a3e10["GelInsertBase"] b96b941f_c2be_27db_c79e_5975e751c4a6["insert.ts"] 47f802c3_39d4_8a05_ef43_b3ba205a3e10 -->|defined in| b96b941f_c2be_27db_c79e_5975e751c4a6 bdd2399c_4c4e_3bc3_7747_cfa68a481f95["constructor()"] 47f802c3_39d4_8a05_ef43_b3ba205a3e10 -->|method| bdd2399c_4c4e_3bc3_7747_cfa68a481f95 2b64ef75_c2a6_42ec_6465_69fd90b7bd28["returning()"] 47f802c3_39d4_8a05_ef43_b3ba205a3e10 -->|method| 2b64ef75_c2a6_42ec_6465_69fd90b7bd28 57a89d31_0c82_a1d2_cb7c_901b73412110["getSQL()"] 47f802c3_39d4_8a05_ef43_b3ba205a3e10 -->|method| 57a89d31_0c82_a1d2_cb7c_901b73412110 c899867d_099a_19b5_d85d_e2c157d225a0["toSQL()"] 47f802c3_39d4_8a05_ef43_b3ba205a3e10 -->|method| c899867d_099a_19b5_d85d_e2c157d225a0 0788f86f_9aca_b184_75cc_a814c0abfda9["_prepare()"] 47f802c3_39d4_8a05_ef43_b3ba205a3e10 -->|method| 0788f86f_9aca_b184_75cc_a814c0abfda9 70fb4878_083e_4b7e_3f4e_6e4e023efe29["prepare()"] 47f802c3_39d4_8a05_ef43_b3ba205a3e10 -->|method| 70fb4878_083e_4b7e_3f4e_6e4e023efe29 ddb8c334_962b_1d05_abab_7d21042e2d69["$dynamic()"] 47f802c3_39d4_8a05_ef43_b3ba205a3e10 -->|method| ddb8c334_962b_1d05_abab_7d21042e2d69
Relationship Graph
Source Code
drizzle-orm/src/gel-core/query-builders/insert.ts lines 220–410
export class GelInsertBase<
TTable extends GelTable,
TQueryResult extends GelQueryResultHKT,
TReturning extends Record<string, unknown> | undefined = undefined,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
TDynamic extends boolean = false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
TExcludedMethods extends string = never,
> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>
implements
RunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,
SQLWrapper
{
static override readonly [entityKind]: string = 'GelInsert';
private config: GelInsertConfig<TTable>;
constructor(
table: TTable,
values: GelInsertConfig['values'],
private session: GelSession,
private dialect: GelDialect,
withList?: Subquery[],
select?: boolean,
overridingSystemValue_?: boolean,
) {
super();
this.config = { table, values: values as any, withList, select, overridingSystemValue_ };
}
/**
* 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<GelInsertReturningAll<this, TDynamic>, TDynamic, 'returning'>;
returning<TSelectedFields extends SelectedFieldsFlat>(
fields: TSelectedFields,
): GelInsertWithout<GelInsertReturning<this, TDynamic, TSelectedFields>, TDynamic, 'returning'>;
returning(
fields: SelectedFieldsFlat = this.config.table[Table.Symbol.Columns],
): GelInsertWithout<AnyGelInsert, TDynamic, 'returning'> {
this.config.returning = orderSelectedFields<GelColumn>(fields);
return this as any;
}
/**
* Adds an `on conflict do nothing` clause to the query.
*
* Calling this method simply avoids inserting a row as its alternative action.
*
* See docs: {@link https://orm.drizzle.team/docs/insert#on-conflict-do-nothing}
*
* @param config The `target` and `where` clauses.
*
* @example
* ```ts
* // Insert one row and cancel the insert if there's a conflict
* await db.insert(cars)
* .values({ id: 1, brand: 'BMW' })
* .onConflictDoNothing();
*
* // Explicitly specify conflict target
* await db.insert(cars)
* .values({ id: 1, brand: 'BMW' })
* .onConflictDoNothing({ target: cars.id });
Domain
Source
Frequently Asked Questions
What is the GelInsertBase class?
GelInsertBase is a class in the drizzle-orm codebase, defined in drizzle-orm/src/gel-core/query-builders/insert.ts.
Where is GelInsertBase defined?
GelInsertBase is defined in drizzle-orm/src/gel-core/query-builders/insert.ts at line 220.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free