Skip to main content
Version: 5.2

TruncateQueryBuilder <T>

Type parameters

  • T

Hierarchy

Index

Properties

readonlyalias

alias: string

Methods

addSelect

andWhere

as

  • as(alias: string): QueryBuilder<any, any>
  • Returns knex instance with sub-query aliased with given alias. You can provide EntityName.propName as alias, then the field name will be used based on the metadata


    Parameters

    • alias: string

    Returns QueryBuilder<any, any>

cache

  • cache(config?: number | boolean | [string, number]): QueryBuilder<T>
  • Parameters

    • config: number | boolean | [string, number] = true

    Returns QueryBuilder<T>

clone

count

  • Parameters

    • optionalfield: string | string[]
    • distinct: boolean = false

    Returns CountQueryBuilder<T>

delete

  • Parameters

    • optionalcond: any

    Returns DeleteQueryBuilder<T>

execute

  • execute<U>(method?: get | all | run, mapResults?: boolean): Promise<U>
  • Type parameters

    Parameters

    • optionalmethod: get | all | run
    • optionalmapResults: boolean

    Returns Promise<U>

getAliasForJoinPath

  • getAliasForJoinPath(path?: string): undefined | string
  • Parameters

    • optionalpath: string

    Returns undefined | string

getCount

  • getCount(field?: string | string[], distinct?: boolean): Promise<number>
  • Executes count query (without offset and limit), returning total count of results


    Parameters

    • optionalfield: string | string[]
    • optionaldistinct: boolean

    Returns Promise<number>

getFormattedQuery

  • getFormattedQuery(): string
  • Returns raw interpolated query string with all the parameters inlined.


    Returns string

getKnex

  • getKnex(): QueryBuilder<any, any>
  • Returns QueryBuilder<any, any>

getKnexQuery

  • getKnexQuery(): QueryBuilder<any, any>
  • Returns QueryBuilder<any, any>

getNextAlias

  • getNextAlias(entityName?: string): string
  • Parameters

    • entityName: string = 'e'

    Returns string

getParams

  • getParams(): readonly Value[]
  • Returns the list of all parameters for this query.


    Returns readonly Value[]

getQuery

  • getQuery(): string
  • Returns the query with parameters as wildcards.


    Returns string

groupBy

  • groupBy(fields: string | keyof T | readonly (string | keyof T)[]): QueryBuilder<T>
  • Parameters

    • fields: string | keyof T | readonly (string | keyof T)[]

    Returns QueryBuilder<T>

having

  • Parameters

    • cond: any = {}
    • optionalparams: any[]

    Returns QueryBuilder<T>

ignore

  • Returns QueryBuilder<T>

indexHint

  • Adds index hint to the FROM clause.


    Parameters

    • sql: string

    Returns QueryBuilder<T>

insert

join

  • join(field: string, alias: string, cond?: any, type?: innerJoin | leftJoin | pivotJoin, path?: string): QueryBuilder<T>
  • Parameters

    • field: string
    • alias: string
    • cond: any = {}
    • type: innerJoin | leftJoin | pivotJoin = 'innerJoin'
    • optionalpath: string

    Returns QueryBuilder<T>

joinAndSelect

  • joinAndSelect(field: string, alias: string, cond?: any, type?: innerJoin | leftJoin | pivotJoin, path?: string): SelectQueryBuilder<T>
  • Parameters

    • field: string
    • alias: string
    • cond: any = {}
    • type: innerJoin | leftJoin | pivotJoin = 'innerJoin'
    • optionalpath: string

    Returns SelectQueryBuilder<T>

leftJoin

  • leftJoin(field: string, alias: string, cond?: any): QueryBuilder<T>
  • Parameters

    • field: string
    • alias: string
    • cond: any = {}

    Returns QueryBuilder<T>

leftJoinAndSelect

  • Parameters

    • field: string
    • alias: string
    • cond: any = {}

    Returns SelectQueryBuilder<T>

limit

  • Parameters

    • optionallimit: number
    • offset: number = 0

    Returns QueryBuilder<T>

merge

offset

  • Parameters

    • optionaloffset: number

    Returns QueryBuilder<T>

onConflict

  • Parameters

    • fields: string | string[] = []

    Returns QueryBuilder<T>

orWhere

orderBy

raw

  • raw<R>(sql: string, bindings?: ValueDict | RawBinding[]): R
  • Type parameters

    • R = Raw<any>

    Parameters

    • sql: string
    • bindings: ValueDict | RawBinding[] = []

    Returns R

select

setFlag

setFlushMode

setLockMode

  • Parameters

    • optionalmode: LockMode
    • optionaltables: string[]

    Returns QueryBuilder<T>

then

  • then<TResult1, TResult2>(onfulfilled?: null | (value: QueryResult<T>) => TResult1 | PromiseLike<TResult1>, onrejected?: null | (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<QueryResult<T>>
  • Type parameters

    Parameters

    • optionalonfulfilled: null | (value: QueryResult<T>) => TResult1 | PromiseLike<TResult1>
    • optionalonrejected: null | (reason: any) => TResult2 | PromiseLike<TResult2>

    Returns Promise<QueryResult<T>>

truncate

unsetFlag

update

where

  • Parameters

    • cond: string | QBFilterQuery<T>
    • optionalparams: any[] | $and | $or
    • optionaloperator: $and | $or

    Returns TruncateQueryBuilder<T>

withSchema

  • Parameters

    • optionalschema: string

    Returns QueryBuilder<T>

withSubQuery

  • withSubQuery(subQuery: QueryBuilder<any, any>, alias: string): QueryBuilder<T>
  • Parameters

    • subQuery: QueryBuilder<any, any>
    • alias: string

    Returns QueryBuilder<T>