@breautek/storm
Version:
Object-Oriented REST API framework
48 lines (47 loc) • 2.01 kB
TypeScript
import { IDatabaseConnection } from './IDatabaseConnection';
import { IQueryable } from './IQueryable';
export declare abstract class Query<TQueryParameters = any, TQueryResultSet = any, TQueryPostProcessedResultSet = TQueryResultSet> implements IQueryable<TQueryPostProcessedResultSet> {
private $params;
constructor(parameters?: TQueryParameters);
/**
* @returns parameters that was passed into the constructor.
*/
getParameters(): TQueryParameters;
/**
* Query implementations may override this API to augment the parameters.
*
* @returns parameters that will be used when this query is ran.
*/
getParametersForQuery(): Record<string, any>;
protected abstract _getQuery(connection: IDatabaseConnection): string;
getQuery(connection: IDatabaseConnection): string;
/**
* Overridable to execute statements before the main query.
* Can be used to set session variables or create temporary tables, etc.
*
* @param connection
* @returns
*/
onPreQuery(connection: IDatabaseConnection): Promise<void>;
/**
* Overridable to execute statements after the main query.
* Can be used to clean up session variables or temporary tables, etc
*
* Unlike {@link onPostProcess}, this hook does not provide the result set,
* and will be invoked even if the main query produces an error.
*
* @since 8.3.0
*
* @param connection
* @returns {void}
*/
onPostQuery(connection: IDatabaseConnection): Promise<void>;
/**
* Override to augment/manipulate the returned result set.
*
* @param connection The connection object used for this query execution. Useful if further queries are required.
* @param resultset The original result set
*/
onPostProcess(connection: IDatabaseConnection, resultSet: TQueryResultSet): Promise<TQueryPostProcessedResultSet>;
execute(connection: IDatabaseConnection): Promise<TQueryPostProcessedResultSet>;
}