sphinxql
Version:
SphinxQL query builder for Node.JS. Supports Sphinx search(2.x and 3.x) and Manticore search
24 lines (19 loc) • 620 B
text/typescript
import StatementBuilderBase from '../StatementBuilderBase';
export default class OrderByExprStatement implements StatementBuilderBase {
protected columnExpr: string;
protected order: string;
protected readonly defaultOrder: string = 'DESC';
constructor(columnExpr: string, order?: string) {
if (!columnExpr.length) {
throw Error(`column/expression can't be empty`);
}
this.columnExpr = columnExpr;
this.order = order;
}
public build(): string {
if (this.order) {
return `${this.columnExpr} ${this.order}`;
}
return `${this.columnExpr} ${this.defaultOrder}`;
}
}