UNPKG

database-builder

Version:

Library to assist in creating and maintaining SQL commands.

113 lines (112 loc) 6.71 kB
import { ExpressionOrValueEnum } from "./enums/expression-or-value-enum"; import * as moment from "moment"; import { DatabaseHelper } from "../database-helper"; import { ProjectionBuilder } from "../crud/projection-builder"; import { Expression, LambdaExpression, ReturnExpression } from "lambda-expression"; import { LambdaMetadata } from "./lambda-metadata"; import { ExpressionOrColumnEnum } from "./enums/expression-or-column-enum"; import { FieldType } from "./enums/field-type"; import { ColumnType } from "./enums/column-type"; import { ProjectionCompiled } from "../crud/projection-compiled"; import { ProjectionsHelper } from "./projections-helper"; import { ColumnParams } from "./column-params"; import { ColumnRef } from "./column-ref"; import { PlanRef } from "./plan-ref"; import { ReplacementParam } from "./replacement-param"; import { QueryBuilder } from "../crud"; import { MetadataTable } from "../metadata-table"; import { MetadataTableBase } from "../metadata-table-base"; import { QueryCompiled } from "."; import { Resultable } from "./resultable"; import { SqlCompilable } from "../crud/sql-compilable"; import { DatabaseResult } from "../definitions/database-definition"; export declare type ParamType = ValueType | ReplacementParam; export declare type ValueType = number | string | boolean; export declare type ValueTypeToParse = ValueType | moment.Moment | Date | object; export declare type TypeOrString<T> = (new () => T) | string; export declare type TQuery = QueryCompiled[] | SqlCompilable; export declare type ExpressionOrColumn<TReturn, T> = ReturnExpression<TReturn, T> | string; export declare type ExpressionQuery<TReturn, T> = ExpressionOrColumn<TReturn, T> | TQuery; export declare type TypeOrderBy<TReturn, T> = ExpressionOrColumn<TReturn, T> | PlanRef | number | QueryCompiled | QueryCompiled[]; export declare type TypeWhere<T> = Expression<T> | ValueTypeToParse | ColumnRef | ProjectionsHelper<T> | PlanRef; export declare type TypeProjection<T> = ProjectionsHelper<T> | ColumnRef | PlanRef; export declare type ExpressionProjection<TReturn, T> = TypeProjection<T> | ExpressionOrColumn<TReturn, T>; export declare type ProjectionOrValue<T> = ProjectionBuilder<T> | ProjectionsHelper<T> | ValueTypeToParse; export declare class Utils { static REPLACEABLE_ALIAS: string; static readonly DEFAULT_VALUES: { BOOLEAN: boolean; NUMBER: number; STRING: string; MOMENT: moment.Moment; DATE: Date; }; private static _expressionUtils; private static _databaseHelper; static GUID(): string; static isFlag(value: any, flag: any): boolean; static is(value: any, type: string): boolean; static isArray(value: any): value is any[]; static isString(value: any): boolean; static isObject(value: any): boolean; static isNumber(value: any): boolean; static isBoolean(value: any): boolean; static isOnlyNumber(value: any): boolean; static isNull(value: any): boolean; static isStartWithNumber(value: any): boolean; static isValueNumber(value: any): boolean; static isValueBoolean(value: any): boolean; static isReservedBoolean(value: any): boolean; static isFunction(value: any): boolean; static isDate(value: any): boolean; static isMoment(value: any): boolean; static isQuery(instance: any): boolean; static isQueryBuilder(instance: any): boolean; static isProjectionBuilder(projectionCandidate: any): boolean; static isProjectionCompiled(projectionCandidate: any): boolean; static isProjectionsHelper(projectionCandidate: any): boolean; static isValueType(value: ValueType): boolean; static isValueTypeToParse(value: any): boolean; static isWhereBuilder(whereCandidate: any): boolean; static isColumnRef(instance: any): boolean; static isPlanRef(instance: any): boolean; static isResultable(instance: any): instance is Resultable; static isEmpty(value: any): boolean; static isQueryCompiled(value: any): boolean; static isQueryCompiledArray(value: any): boolean; static isQueryCompilable(value: any): boolean; static isTQuery(value: any): boolean; static getMapperTable<T>(typeT: (new () => T) | QueryBuilder<T> | { _builder: () => QueryBuilder<T>; }, getMapper: (tKey: (new () => any) | string) => MetadataTable<any>): MetadataTableBase<T>; static expressionOrColumn<TReturn, T>(value: ExpressionOrColumn<TReturn, T>): ExpressionOrColumnEnum; static expressionOrValue<T>(value: TypeWhere<T>): ExpressionOrValueEnum; static getColumn<TReturn, T>(expression: ExpressionOrColumn<TReturn, T>, separator?: string): string; static getColumnWhere<T>(expression: TypeWhere<T>): ColumnParams; static resolveExpressionProjection<TReturn, T>(projection: ExpressionProjection<TReturn, T>): ProjectionCompiled; static getFieldExpression<T>(expression: Expression<T>): string; static getValue<TReturn, T>(instance: any | Array<any>, expression: ExpressionOrColumn<TReturn, T>): Array<TReturn>; static getValues<TReturn, T>(instance: Array<any>, expression: ExpressionOrColumn<TReturn, T>): Array<TReturn>; static getTypeByValue(value: ValueTypeToParse): FieldType; static getType(instance: Array<ValueTypeToParse>): FieldType; static getType(instance: ValueTypeToParse): FieldType; static getType<TReturn extends ValueTypeToParse, T>(instance: any, expression: ExpressionOrColumn<TReturn, T>): FieldType; static getValueType(value: ValueTypeToParse | Array<ValueTypeToParse>, type?: FieldType): Array<ValueType>; static getValuesType(values: Array<ValueTypeToParse>, type?: FieldType): Array<ValueType>; static parseColumnType(type: FieldType): ColumnType; static isNameColumn(column: string): boolean; static isValue(value: any): boolean; static isValueDefault(value: any): boolean; static normalizeSqlString(inputSql: string): string; static getLambdaMetadata<T>(expression: LambdaExpression<T>): LambdaMetadata; static clearParam(param: ValueTypeToParse): ValueTypeToParse; static clearParamLambda(param: ValueTypeToParse): ValueTypeToParse; static addAlias(column: string | Resultable, alias: string): string; private static isColumnReservedNameOrNotAllowed; private static getLambdaColumnMetadata; private static conditionSql; private static isEquivalentNullExpression; private static getExpressionUtils; static getDatabaseHelper(): DatabaseHelper; static objectToDatabaseResult(rows: any[], rowsAffected?: number, insertId?: any): DatabaseResult; }