orderBy

abstract fun orderBy(column: KQLiteColumn<*>): DeleteStatement<T>
abstract fun orderBy(column: OrderColumn): DeleteStatement<T>

Same as calling orderBy(column, null)


abstract fun orderBy(column: KQLiteColumn<*>, sort: Sort?): DeleteStatement<T>

Adds an ORDER BY clause to the DELETE statement, which is used in conjunction with LIMIT.

SQLite supports ORDER BY in DELETE statements to specify the order in which rows are deleted when a LIMIT is also present. This function allows sorting the rows based on a single column.

This function can be called only once per DeleteStatement. Subsequent calls will override the previously set ORDER BY clause.

Note: This is a non-standard SQL feature specific to SQLite.

Example:

// Deletes the 5 oldest users from the table
MyTable
.delete()
.orderBy(MyTable.creationDate, Sort.ASC)
.limit(5)
.execute()

Return

The DeleteStatement instance for further chaining.

Author

MOHAMMAD AZIM ANSARI

Parameters

column

The KQLiteColumn to sort by.

sort

The sort order (Sort.ASC for ascending or Sort.DESC for descending). If null, the database's default order (usually ascending) will be used.

See also


abstract fun orderBy(orderColumn1: OrderColumn, orderColumn2: OrderColumn?): DeleteStatement<T>

Adds an ORDER BY clause to the DELETE statement, which is used in conjunction with LIMIT.

SQLite supports ORDER BY in DELETE statements to specify the order in which rows are deleted when a LIMIT is also present. This overload allows sorting by one or more columns using OrderColumn objects, which can define complex sorting criteria (e.g., NULLS FIRST/LAST).

This function can be called only once per DeleteStatement. Subsequent calls will override the previously set ORDER BY clause.

Note: This is a non-standard SQL feature specific to SQLite.

Example:

// Deletes the 10 most recently updated, inactive users, case insensitive
MyTable
.delete()
.where { it.status EQ "inactive" }
.orderBy(OrderColumn(MyTable.lastUpdated, Collate.NOCASE, Sort.DESC))
.limit(10)
.execute()

Return

The DeleteStatement instance for further chaining.

Author

MOHAMMAD AZIM ANSARI

Parameters

orderColumn1

The primary OrderColumn to sort by.

orderColumn2

An optional secondary OrderColumn for more complex sorting.

See also