import type { AnyQueryBuilder, WithRelationType } from './query-methods' import type { ICollection, IPaginator, IPaginatorParams } from './utils' import type BModel from 'src/browser/model' import type Builder from 'src/builder' import type { IModel } from './modeling' import type { IQueryBuilder } from './query-builder' import type { Knex } from 'knex' import type Model from 'src/model' import type { TFunction } from './generics' type BaseBuilder | IModel> = Omit< IQueryBuilder, | 'destroy' | 'clone' | 'get' | 'skip' | 'limit' | 'take' | 'offset' | 'chunk' | 'forPage' | 'orWhere' | 'pluck' > export interface IScope { apply(builder: Builder, model: Model): void } // @ts-expect-error Errors will come from builder differences but that is fine export interface IBuilder | IModel> extends BaseBuilder { connector: IQueryBuilder & Knex.QueryBuilder & { _statements: any[]; _single: any } & Knex asProxy(): IBuilder chunk( count: number, callback: (rows: ICollection) => any, ): Promise enforceOrderBy(): void idOf(id: string | number): this clone(): IBuilder forPage(page: number, perPage?: number): this insert(...attributes: any[]): Promise update(attributes: any): Promise increment(column: string, amount?: number, extra?: any): Promise decrement(column: string, amount?: number, extra?: any): Promise addUpdatedAtColumn(values: any): any delete(): Promise softDelete(): boolean | Promise forceDelete(): boolean | Promise restore(): boolean | Promise withTrashed(): this withoutTrashed(): this onlyTrashed(): this getDeletedAtColumn(): string create(attributes?: any): Promise newModelInstance(attributes?: any): M count(columns?: string): Promise getQuery(): AnyQueryBuilder getModel(): M setModel(model: M): this setTable(table: string): this applyScopes(): this scopes(scopes: string[]): this withGlobalScope( identifier: string | number, scope: string | (() => void), ): this withoutGlobalScope(scope: IScope | string): this with(relation: WithRelationType): this with(...relations: WithRelationType[]): this has( relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder) => void | null, ): this orHas(relation: string, operator?: any, count?: number): this doesntHave( relation: string, boolean?: any, callback?: (builder: IBuilder) => void | null, ): this orDoesntHave(relation: string): this whereHas( relation: string, callback?: (builder: IBuilder) => void | IBuilder | null, operator?: any, count?: number, ): this orWhere(...args: any[]): this orWhereHas( relation: string, callback?: (builder: IBuilder) => void | IBuilder | null, operator?: any, count?: number, ): this whereRelation( relation: string, column: string, operator?: any, value?: any, ): this hasNested( relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder) => void | null, ): this canUseExistsForExistenceCheck(operator: string, count: number): boolean addHasWhere( hasQuery: IBuilder, relation: string, operator?: string, count?: number, boolean?: string, ): this withAggregate( relations: string | string[] | object, column: string, action?: string | null, ): this toSql(): object withCount(...relations: WithRelationType[]): this withMax(relation: WithRelationType, column: string): this withMin(relation: WithRelationType, column: string): this withAvg(relation: WithRelationType, column: string): this withSum(relation: WithRelationType, column: string): this withExists(relation: WithRelationType): this related(relation: string): this take(count: number): this skip(count: number): this limit(count: number): this offset(count: number): this first(column?: string | string[]): Promise firstOrFail(column?: string | string[]): Promise findOrFail(key: string | number, columns?: string[]): Promise findOrFail( key: string[] | number[] | ICollection, columns?: string[], ): Promise findOrFail( key: string | number | string[] | number[] | ICollection, columns?: string[], ): Promise findOrNew(id: string | number, columns?: string[]): Promise firstOrNew(attributes?: object, values?: object): Promise firstOrCreate(attributes?: object, values?: object): Promise updateOrCreate(attributes: object, values?: object): Promise latest(column?: string): this oldest(column?: string): this find(key: string | number, columns?: string[]): Promise findMany( keys: string[] | number[] | ICollection, columns?: string[], ): Promise> pluck(column: string): Promise> destroy( ids?: string | number | string[] | number[] | TFunction | ICollection, ): Promise get(columns?: string[]): Promise> all(columns?: string[]): Promise> paginate( page?: number, perPage?: number, ): Promise> [value: string]: any }