Skip to content

toKeysetOrderBySql

function toKeysetOrderBySql(order, columns): string;

Defined in: keyset.ts:384

Render KeysetSpec.orderBy output as an SQL ORDER BY fragment.

The returned string does not include the leading ORDER BY. Column identifiers/expressions are resolved from columns. Plain strings are validated with assertSqlIdentifier; computed expressions must be explicitly wrapped with keysetSqlExpression. No request data should ever be used for column mappings.

Parameter Type
order KeysetSortKey[]
columns KeysetSqlColumns

string

toKeysetOrderBySql(keyset.orderBy("backward"), {
createdAt: "created_at",
id: "id",
});
// "created_at DESC, id DESC"

If a key is missing from columns or a column identifier is unsafe.