@riao/dbal
Version:
30 lines (29 loc) • 984 B
TypeScript
import { ExpressionToken } from '../expression/expression-token';
import { ColumnType } from '../column';
/**
* Database functions are typed by column type, so that users
* gain strong typing when using functions, i.e. the user
* can't assign a date function to a bool column.
*/
export type DatabaseFunctionReturnType = keyof typeof ColumnType;
export declare enum DatabaseFunctionKeys {
AVERAGE = 0,
COUNT = 1,
MIN = 2,
MAX = 3,
SUM = 4,
CURRENT_TIMESTAMP = 5,
DATE = 6,
YEAR = 7,
UUID = 8
}
export interface DatabaseFunction<T extends DatabaseFunctionReturnType = DatabaseFunctionReturnType> {
fn: DatabaseFunctionKeys;
type: T;
params?: any;
}
/**
* A token is returned by database functions, so that it can be
* interpreted during sql generation.
*/
export type DatabaseFunctionToken<T extends DatabaseFunctionReturnType = DatabaseFunctionReturnType> = ExpressionToken & DatabaseFunction<T>;