rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
37 lines (36 loc) • 1.33 kB
TypeScript
import { SimpleSelectQuery } from "../models/SelectQuery";
/**
* SqlSortInjector injects sort conditions into a SelectQuery model,
* creating ORDER BY clauses based on provided sort conditions.
*/
export declare class SqlSortInjector {
private tableColumnResolver?;
constructor(tableColumnResolver?: (tableName: string) => string[]);
/**
* Removes ORDER BY clause from the given query.
* @param query The SelectQuery to modify
* @returns The modified SimpleSelectQuery with ORDER BY clause removed
*/
static removeOrderBy(query: SimpleSelectQuery | string): SimpleSelectQuery;
/**
* Injects sort conditions as ORDER BY clauses into the given query model.
* Appends to existing ORDER BY clause if present.
* @param query The SelectQuery to modify
* @param sortConditions A record of column names and sort conditions
* @returns The modified SimpleSelectQuery
*/
inject(query: SimpleSelectQuery | string, sortConditions: SortConditions): SimpleSelectQuery;
/**
* Validates sort condition for a column
*/
private validateSortCondition;
}
export type SortCondition = {
asc?: boolean;
desc?: boolean;
nullsFirst?: boolean;
nullsLast?: boolean;
};
export type SortConditions = {
[columnName: string]: SortCondition;
};