order By
Same as calling orderBy(column, null)
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
The KQLiteColumn to sort by.
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
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
The primary OrderColumn to sort by.
An optional secondary OrderColumn for more complex sorting.