Module

x/kysely_postgrs_js_dialect/mod.ts>kysely.DeleteQueryBuilder#orderBy

Kysely dialect for PostgreSQL using the Postgres.js client.
Latest
method kysely.DeleteQueryBuilder.prototype.orderBy
import { kysely } from "https://dotland.deno.dev/x/kysely_postgrs_js_dialect@v0.27.4/mod.ts";
const { DeleteQueryBuilder } = kysely;

Adds an order by clause to the query.

orderBy calls are additive. To order by multiple columns, call orderBy multiple times.

The first argument is the expression to order by and the second is the order (asc or desc).

An order by clause in a delete query is only supported by some dialects like MySQL.

See {@link SelectQueryBuilder.orderBy} for more examples.

Examples

Delete 5 oldest items in a table:

await db
  .deleteFrom('pet')
  .orderBy('created_at')
  .limit(5)
  .execute()

The generated SQL (MySQL):

delete from `pet`
order by `created_at`
limit ?

Parameters

orderBy: OrderByExpression<DB, TB, O>
optional
direction: OrderByDirectionExpression