Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

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

Kysely dialect for PostgreSQL using the Postgres.js client.
Latest
method kysely.DeleteQueryBuilder.prototype.orderBy
Re-export
import { kysely } from "https://deno.land/x/kysely_postgrs_js_dialect@v0.27.4/deps.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 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