type ApplyOrderOptions
Description
ApplyOrderOptions is a type that controls order configuration.
Definition
Defaults:
useQuotes = undefinedalias = undefinedalwaysAliasFields = ['id', 'created_at', 'createdAt', 'updated_at', 'updatedAt', 'deleted_at', 'deletedAt']resetPreviousOrder = false
type ApplyOrderOptions = {
useQuotes?: boolean;
alias?: string;
alwaysAliasFields?: string[];
resetPreviousOrder?: boolean;
};
useQuotes: how the field reaches the ORDER BY.- Not set: an entity property under an alias with an entity is written
user.createdAt, which TypeORM maps to its column and whichtake/skipwith joins can order by; anything else is quoted as one identifier with its database column name,"user"."created_at","total". true: always quoted,"user"."created_at".false: written as is,user.createdAt. Only column names are accepted then: anything else throws aTypeError, since an order often comes from a request.
- Not set: an entity property under an alias with an entity is written
alias: alias to prefix every field with.OrderParam.tableAliastakes precedence over it.alwaysAliasFields: withoutalias/tableAlias, only these fields are prefixed with the query's main alias; other fields are used as is (e.g. to order by a selected alias).resetPreviousOrder: drop ORDER BY clauses set earlier on the query before applying this order.
Example
query
.leftJoinAndSelect('user.images', 'images')
.applyOrderFilter(
order,
{ alias: 'user', resetPreviousOrder: true } // ApplyOrderOptions
)
.applyPagination(
pagination,
{ useTakeAndSkip: true }
)