OptionalwithList: Subquery<string, Record<string, unknown>>[]Readonly_Static Readonly[entityA Promise for the completion of the callback.
OptionalplaceholderValues: Record<string, unknown>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 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: https://orm.drizzle.team/docs/delete#delete-with-return
// 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 });
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: https://orm.drizzle.team/docs/delete#delete-with-return
// 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 });
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.
Adds a where clause to the query.
Calling this method will delete only those rows that fulfill a specified condition.
See docs: https://orm.drizzle.team/docs/delete
the where clause.
You can use conditional operators and sql function to filter the rows to be deleted.
// 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:
// 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')));
Attaches a callback for only the rejection of the Promise.