Skip to main content

OrderColumn

Represents one ORDER BY column, optionally schema/table-qualified, with an ascending/descending direction. Select#orderBy() builds OrderColumn instances internally for every string you pass. Extends BaseField.

Constructor

OrderColumn(value: string): OrderColumn
new OrderColumn(value: string): OrderColumn

Dual-callable. value must match [+|-][[schema.]table.]field[ (asc|dsc|desc|ascending|descending)] (case-insensitive suffix) — anything else throws a TypeError ("does not match order column format"). A leading - or a dsc/desc/descending suffix sets _descending; a leading + or an asc/ascending suffix (or no suffix at all) leaves it ascending.

import { Select } from '@sqb/builder';

Select().from('customers').orderBy('-created_at', 'name asc', '+id');
// ... order by created_at desc, name, id

Properties

KeyTypeReadonlyDescription
_typeSerializationType.ORDER_COLUMNYesDiscriminates this node during serialization.
_fieldstringNoThe unqualified column name.
_tablestring | undefinedNoTable qualifier, if present in value.
_schemastring | undefinedNoSchema qualifier, if present in value.
_descendingbooleanNoWhether to render a trailing desc.

Plus everything inherited from BaseField.

Methods

OrderColumn has no chainable methods — it exposes only its serialization logic. Reserved words in _field are escaped (double-quoted) automatically when serialized.

See also