import type { AddSelectMethod, AnyQueryBuilder, FirstOrFailMethod, ForceDeleteMethod, GroupByMethod, JoinMethod, JoinRawMethod, OrderByMethod, OrderByRawMethod, RawInterface, RestoreMethod, ReturningMethod, SelectMethod, SetOperationsMethod, UnionMethod, WhereBetweenMethod, WhereColumnMethod, WhereExistsMethod, WhereFieldExpressionMethod, WhereInMethod, WhereJsonExpressionMethod, WhereMethod, WhereNullMethod, WhereRawMethod, WhereWrappedMethod, } from './query-methods' import type { IPaginator, IPaginatorParams } from './utils' import type { TFunction, TGeneric } from './generics' import type BModel from 'src/browser/model' import type { Column } from 'src/inspector/types/column' import type { ForeignKey } from 'src/inspector/types/foreign-key' import type { IBuilder } from './builder' import type { Knex } from 'knex' import type Model from 'src/model' import type { Table } from 'src/inspector/types/table' export interface SchemaBuilder extends Knex.SchemaBuilder { [k: string]: any /** * Retrieve all tables in the current database. */ tables (): Promise /** * Retrieve the table info for the given table, or all tables if no table is specified. * * @param table */ tableInfo (table?: string): Promise /** * Retrieve all columns in a given table, or all columns if no table is specified. * * @param table */ columns (table?: string): Promise<{ table: string; column: string }[]> /** * Retrieve all columns from a given table. Returns all columns if table parameter is undefined. * * @param table * @param column */ columnInfo (table?: string, column?: string): Promise /** * Retrieve the primary key column for a given table. * * @param table */ primary (table: string): Promise /** * Retrieve all configured foreign key constraints */ foreignKeys (): Promise } interface AsMethod { (alias: string): QB } export interface IStatement { grouping: string direction: string type: string value: () => any not: boolean nulls: boolean bool: 'and' | 'or' | 'not' } export type IConnector = Knex & Knex.QueryBuilder export interface IQueryBuilder { // connector: IQueryBuilder query: IBuilder schema: SchemaBuilder _statements: IStatement[] table (name: string): IQueryBuilder select: SelectMethod addSelect: AddSelectMethod columns: SelectMethod column: SelectMethod distinct: SelectMethod returning: ReturningMethod distinctOn: SelectMethod as: AsMethod asProxy (): IQueryBuilder where: WhereMethod firstOrFail: FirstOrFailMethod forceDelete: ForceDeleteMethod andWhere: WhereMethod // orWhere: WhereMethod orWhere (...args: any[]): this whereNot: WhereMethod andWhereNot: WhereMethod orWhereNot: WhereMethod whereRaw: WhereRawMethod orWhereRaw: WhereRawMethod andWhereRaw: WhereRawMethod whereWrapped: WhereWrappedMethod havingWrapped: WhereWrappedMethod whereExists: WhereExistsMethod orWhereExists: WhereExistsMethod whereNotExists: WhereExistsMethod orWhereNotExists: WhereExistsMethod restore: RestoreMethod whereIn: WhereInMethod orWhereIn: WhereInMethod whereNotIn: WhereInMethod orWhereNotIn: WhereInMethod whereBetween: WhereBetweenMethod orWhereBetween: WhereBetweenMethod andWhereBetween: WhereBetweenMethod whereNotBetween: WhereBetweenMethod orWhereNotBetween: WhereBetweenMethod andWhereNotBetween: WhereBetweenMethod whereNull: WhereNullMethod orWhereNull: WhereNullMethod whereNotNull: WhereNullMethod orWhereNotNull: WhereNullMethod whereColumn: WhereColumnMethod orWhereColumn: WhereColumnMethod andWhereColumn: WhereColumnMethod whereNotColumn: WhereColumnMethod orWhereNotColumn: WhereColumnMethod andWhereNotColumn: WhereColumnMethod whereJsonIsArray: WhereFieldExpressionMethod orWhereJsonIsArray: WhereFieldExpressionMethod whereJsonNotArray: WhereFieldExpressionMethod orWhereJsonNotArray: WhereFieldExpressionMethod whereJsonIsObject: WhereFieldExpressionMethod orWhereJsonIsObject: WhereFieldExpressionMethod whereJsonNotObject: WhereFieldExpressionMethod orWhereJsonNotObject: WhereFieldExpressionMethod whereJsonHasAny: WhereJsonExpressionMethod orWhereJsonHasAny: WhereJsonExpressionMethod whereJsonHasAll: WhereJsonExpressionMethod orWhereJsonHasAll: WhereJsonExpressionMethod having: WhereMethod andHaving: WhereMethod orHaving: WhereMethod havingRaw: WhereRawMethod orHavingRaw: WhereRawMethod havingIn: WhereInMethod orHavingIn: WhereInMethod havingNotIn: WhereInMethod orHavingNotIn: WhereInMethod havingNull: WhereNullMethod orHavingNull: WhereNullMethod havingNotNull: WhereNullMethod orHavingNotNull: WhereNullMethod havingExists: WhereExistsMethod orHavingExists: WhereExistsMethod havingNotExists: WhereExistsMethod orHavingNotExists: WhereExistsMethod havingBetween: WhereBetweenMethod orHavingBetween: WhereBetweenMethod havingNotBetween: WhereBetweenMethod orHavingNotBetween: WhereBetweenMethod union: UnionMethod unionAll: UnionMethod intersect: SetOperationsMethod join: JoinMethod joinRaw: JoinRawMethod innerJoin: JoinMethod leftJoin: JoinMethod leftOuterJoin: JoinMethod rightJoin: JoinMethod rightOuterJoin: JoinMethod outerJoin: JoinMethod fullOuterJoin: JoinMethod crossJoin: JoinMethod orderBy: OrderByMethod orderByRaw: OrderByRawMethod groupBy: GroupByMethod groupByRaw: RawInterface transaction (callback?: TFunction): Promise | null | undefined destroy (callback: TFunction): Promise destroy (): Promise clone (): IQueryBuilder raw: Knex.RawQueryBuilder get (columns?: string[]): Promise first (columns?: string[]): Promise find (key: string | number, columns?: string[]): Promise insert (attributes: any): Promise update (...attributes: any[]): Promise delete (): Promise exists (): Promise count (column?: string): Promise min (column: string): Promise max (column: string): Promise sum (column: string): Promise avg (column: string): Promise skip (count: number): this take (count: number): this limit (count: number): this offset (count: number): this pluck (column: string): Promise> chunk (count: number, callback: (rows: M[]) => any): Promise forPage (page: number, perPage?: number): this paginate ( page?: number, perPage?: number, ): Promise> }