OptionalwithList: Subquery<string, Record<string, unknown>>[]Optionalselect: booleanReadonly_Static Readonly[entityA Promise for the completion of the callback.
Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
OptionalonFinally: (() => void) | nullA Promise for the completion of the callback.
Adds an on conflict do nothing clause to the query.
Calling this method simply avoids inserting a row as its alternative action.
See docs: https://orm.drizzle.team/docs/insert#on-conflict-do-nothing
Optionalconfig: { target?: IndexColumn | IndexColumn[]; where?: SQL<unknown> }The target and where clauses.
Adds an on conflict do update clause to the query.
Calling this method will update the existing row that conflicts with the row proposed for insertion as its alternative action.
See docs: https://orm.drizzle.team/docs/insert#upserts-and-conflicts
The target, set and where clauses.
// Update the row if there's a conflict
await db.insert(cars)
.values({ id: 1, brand: 'BMW' })
.onConflictDoUpdate({
target: cars.id,
set: { brand: 'Porsche' }
});
// Upsert with 'where' clause
await db.insert(cars)
.values({ id: 1, brand: 'BMW' })
.onConflictDoUpdate({
target: cars.id,
set: { brand: 'newBMW' },
where: sql`${cars.createdAt} > '2023-01-01'::date`,
});
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: https://orm.drizzle.team/docs/insert#insert-returning
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: https://orm.drizzle.team/docs/insert#insert-returning
OptionalshouldAttaches callbacks for the resolution and/or rejection of the Promise.
OptionalonFulfilled: OptionalonRejected: ((reason: any) => TResult2 | PromiseLike<TResult2>) | nullA Promise for the completion of which ever callback is executed.
Attaches a callback for only the rejection of the Promise.