SQLiteInsertBase Class — drizzle-orm Architecture
Architecture documentation for the SQLiteInsertBase class in insert.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD fd9d3b22_d4f5_65bb_f267_7230f9181031["SQLiteInsertBase"] 84987318_b83b_9a2c_d793_542fa0b46175["insert.ts"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|defined in| 84987318_b83b_9a2c_d793_542fa0b46175 cd81a0a2_9003_f022_9c9f_db9fc1f812e6["constructor()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| cd81a0a2_9003_f022_9c9f_db9fc1f812e6 3550df4c_991e_68a1_9e6e_1f82cf31a63f["returning()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| 3550df4c_991e_68a1_9e6e_1f82cf31a63f a7481a24_eb8f_555b_d34d_76f669a24719["onConflictDoNothing()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| a7481a24_eb8f_555b_d34d_76f669a24719 8397b2ec_5b63_5b3f_bbac_b94f8833e83e["onConflictDoUpdate()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| 8397b2ec_5b63_5b3f_bbac_b94f8833e83e 2daf9e3a_9249_68dd_04e5_a0dfb55f8a05["getSQL()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| 2daf9e3a_9249_68dd_04e5_a0dfb55f8a05 8a1baeda_2c91_0569_6e73_8cedaff85739["toSQL()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| 8a1baeda_2c91_0569_6e73_8cedaff85739 aaa83d1f_b084_babd_31ef_eb03a1137646["_prepare()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| aaa83d1f_b084_babd_31ef_eb03a1137646 d4ffbfbd_6876_b868_3e9c_f3a676f57a42["prepare()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| d4ffbfbd_6876_b868_3e9c_f3a676f57a42 39c69906_cda5_6589_dc29_b3864034a449["execute()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| 39c69906_cda5_6589_dc29_b3864034a449 63a44105_f5e7_dd11_fecf_1e68726b7c83["$dynamic()"] fd9d3b22_d4f5_65bb_f267_7230f9181031 -->|method| 63a44105_f5e7_dd11_fecf_1e68726b7c83
Relationship Graph
Source Code
drizzle-orm/src/sqlite-core/query-builders/insert.ts lines 223–420
export class SQLiteInsertBase<
TTable extends SQLiteTable,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
TResultType extends 'sync' | 'async',
TRunResult,
TReturning = 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 ? TRunResult : TReturning[]>
implements RunnableQuery<TReturning extends undefined ? TRunResult : TReturning[], 'sqlite'>, SQLWrapper
{
static override readonly [entityKind]: string = 'SQLiteInsert';
/** @internal */
config: SQLiteInsertConfig<TTable>;
constructor(
table: TTable,
values: SQLiteInsertConfig['values'],
private session: SQLiteSession<any, any, any, any>,
private dialect: SQLiteDialect,
withList?: Subquery[],
select?: boolean,
) {
super();
this.config = { table, values: values as any, withList, select };
}
/**
* 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(): SQLiteInsertReturningAll<this, TDynamic>;
returning<TSelectedFields extends SelectedFieldsFlat>(
fields: TSelectedFields,
): SQLiteInsertReturning<this, TDynamic, TSelectedFields>;
returning(
fields: SelectedFieldsFlat = this.config.table[SQLiteTable.Symbol.Columns],
): SQLiteInsertWithout<AnySQLiteInsert, TDynamic, 'returning'> {
this.config.returning = orderSelectedFields<SQLiteColumn>(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 SQLiteInsertBase class?
SQLiteInsertBase is a class in the drizzle-orm codebase, defined in drizzle-orm/src/sqlite-core/query-builders/insert.ts.
Where is SQLiteInsertBase defined?
SQLiteInsertBase is defined in drizzle-orm/src/sqlite-core/query-builders/insert.ts at line 223.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free