Skip to main content
Version: 6.4

UpdateQueryBuilder <T>

Hierarchy

Index

Properties

inheritedalias

alias: string

inheritedhelper

helper: QueryBuilderHelper

inheritedmainAlias

mainAlias: Alias<T>

Methods

inheritedaddSelect

inheritedandHaving

inheritedandWhere

  • andWhere(cond: QBFilterQuery<T>): this
  • andWhere(cond: string, params?: any[]): this
  • Parameters

    Returns this

inheritedapplyFilters

  • Apply filters to the QB where condition.


    Parameters

    Returns Promise<void>

inheritedas

  • 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>

inheritedcache

  • cache(config?: number | boolean | [string, number]): this
  • Parameters

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

    Returns this

inheritedclone

  • clone(reset?: boolean | string[]): QueryBuilder<T, never, never, never>
  • Parameters

    • optionalreset: boolean | string[]

    Returns QueryBuilder<T, never, never, never>

inheritedcomment

  • comment(comment: string | string[]): this
  • Prepend comment to the sql query using the syntax /* ... *&#8205;/. Some characters are forbidden such as /*, *&#8205;/ and ?.


    Parameters

    • comment: string | string[]

    Returns this

inheritedcount

  • count(field?: EntityKeyOrString<T> | EntityKeyOrString<T>[], distinct?: boolean): CountQueryBuilder<T>
  • Parameters

    • optionalfield: EntityKeyOrString<T> | EntityKeyOrString<T>[]
    • distinct: boolean = false

    Returns CountQueryBuilder<T>

inheriteddelete

inheriteddistinct

inheriteddistinctOn

  • distinctOn(fields: EntityKeyOrString<T> | EntityKeyOrString<T>[]): SelectQueryBuilder<T, any, any, never>
  • postgres only


    Parameters

    • fields: EntityKeyOrString<T> | EntityKeyOrString<T>[]

    Returns SelectQueryBuilder<T, any, any, never>

inheritedexecute

  • execute(method?: get | all | run, mapResults?: boolean): Promise<Result>
  • Executes this QB and returns the raw results, mapped to the property names (unless disabled via last parameter). Use method to specify what kind of result you want to get (array/single/meta).


    Parameters

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

    Returns Promise<Result>

inheritedfrom

  • Specifies FROM which entity's table select/update/delete will be executed, removing all previously set FROM-s. Allows setting a main string alias of the selection data.


    Parameters

    • target: QueryBuilder<Entity, never, never, never>
    • optionalaliasName: string

    Returns SelectQueryBuilder<Entity, any, any, never>

inheritedgetCount

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


    Parameters

    • optionalfield: EntityKeyOrString<T> | EntityKeyOrString<T>[]
    • optionaldistinct: boolean

    Returns Promise<number>

inheritedgetFormattedQuery

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


    Returns string

inheritedgetKnex

  • getKnex(processVirtualEntity?: boolean): QueryBuilder<any, any>
  • Parameters

    • processVirtualEntity: boolean = true

    Returns QueryBuilder<any, any>

inheritedgetKnexQuery

  • getKnexQuery(processVirtualEntity?: boolean): QueryBuilder<any, any>
  • Parameters

    • processVirtualEntity: boolean = true

    Returns QueryBuilder<any, any>

inheritedgetLoggerContext

  • getLoggerContext(): T
  • Gets logger context for this query builder.


    Returns T

inheritedgetParams

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


    Returns readonly Value[]

inheritedgetQuery

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


    Returns string

inheritedgetResultAndCount

  • getResultAndCount(): Promise<[T[], number]>
  • Executes the query, returning both array of results and total count query (without offset and limit).


    Returns Promise<[T[], number]>

inheritedgroupBy

  • groupBy(fields: EntityKeyOrString<T> | readonly EntityKeyOrString<T>[]): SelectQueryBuilder<T, any, any, never>
  • Parameters

    • fields: EntityKeyOrString<T> | readonly EntityKeyOrString<T>[]

    Returns SelectQueryBuilder<T, any, any, never>

inheritedhasFlag

  • Parameters

    Returns boolean

inheritedhaving

  • Parameters

    • cond: string | QBFilterQuery = {}
    • optionalparams: any[]
    • optionaloperator: $and | $or

    Returns SelectQueryBuilder<T, any, any, never>

inheritedhintComment

  • hintComment(comment: string | string[]): this
  • Add hints to the query using comment-like syntax /*+ ... *&#8205;/. MySQL and Oracle use this syntax for optimizer hints. Also various DB proxies and routers use this syntax to pass hints to alter their behavior. In other dialects the hints are ignored as simple comments.


    Parameters

    • comment: string | string[]

    Returns this

inheritedignore

  • ignore(): this
  • Returns this

inheritedindexHint

  • indexHint(sql: string): this
  • Adds index hint to the FROM clause.


    Parameters

    • sql: string

    Returns this

inheritedinnerJoin

  • innerJoin(field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never> | Field, alias: Alias, cond?: QBFilterQuery, schema?: string): SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, false>[K] }>
  • Parameters

    • field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never> | Field
    • alias: Alias
    • cond: QBFilterQuery = {}
    • optionalschema: string

    Returns SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, false>[K] }>

inheritedinnerJoinAndSelect

  • innerJoinAndSelect(field: Field | [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>
  • Parameters

    • field: Field | [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>]
    • alias: Alias
    • cond: QBFilterQuery = {}
    • optionalfields: string[]
    • optionalschema: string

    Returns SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>

inheritedinnerJoinLateral

  • innerJoinLateral(field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>, alias: string, cond?: QBFilterQuery, schema?: string): this
  • Parameters

    • field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>
    • alias: string
    • cond: QBFilterQuery = {}
    • optionalschema: string

    Returns this

inheritedinnerJoinLateralAndSelect

  • innerJoinLateralAndSelect(field: [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>
  • Parameters

    • field: [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>]
    • alias: Alias
    • cond: QBFilterQuery = {}
    • optionalfields: string[]
    • optionalschema: string

    Returns SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>

inheritedinsert

inheritedjoin

  • join(field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never> | Field, alias: Alias, cond?: QBFilterQuery, type?: JoinType, path?: string, schema?: string): SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, false>[K] }>
  • Parameters

    • field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never> | Field
    • alias: Alias
    • cond: QBFilterQuery = {}
    • type: JoinType = JoinType.innerJoin
    • optionalpath: string
    • optionalschema: string

    Returns SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, false>[K] }>

inheritedjoinAndSelect

  • joinAndSelect(field: Field | [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>], alias: Alias, cond?: QBFilterQuery, type?: JoinType, path?: string, fields?: string[], schema?: string): SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>
  • Parameters

    • field: Field | [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>]
    • alias: Alias
    • cond: QBFilterQuery = {}
    • type: JoinType = JoinType.innerJoin
    • optionalpath: string
    • optionalfields: string[]
    • optionalschema: string

    Returns SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>

inheritedleftJoin

  • leftJoin(field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never> | Field, alias: Alias, cond?: QBFilterQuery, schema?: string): SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, false>[K] }>
  • Parameters

    • field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never> | Field
    • alias: Alias
    • cond: QBFilterQuery = {}
    • optionalschema: string

    Returns SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, false>[K] }>

inheritedleftJoinAndSelect

  • leftJoinAndSelect(field: Field | [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>
  • Parameters

    • field: Field | [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>]
    • alias: Alias
    • cond: QBFilterQuery = {}
    • optionalfields: string[]
    • optionalschema: string

    Returns SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>

inheritedleftJoinLateral

  • leftJoinLateral(field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>, alias: string, cond?: QBFilterQuery, schema?: string): this
  • Parameters

    • field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>
    • alias: string
    • cond: QBFilterQuery = {}
    • optionalschema: string

    Returns this

inheritedleftJoinLateralAndSelect

  • leftJoinLateralAndSelect(field: [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>
  • Parameters

    • field: [field: Field, qb: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>]
    • alias: Alias
    • cond: QBFilterQuery = {}
    • optionalfields: string[]
    • optionalschema: string

    Returns SelectQueryBuilder<T, any, any, { [ K in string ]: AddToContext<GetType<T, object, Field>, object, Field, Alias, true>[K] }>

inheritedlimit

  • Parameters

    • optionallimit: number
    • offset: number = 0

    Returns SelectQueryBuilder<T, any, any, never>

inheritedmerge

  • Parameters

    Returns this

inheritedoffset

  • Parameters

    • optionaloffset: number

    Returns SelectQueryBuilder<T, any, any, never>

inheritedonConflict

inheritedorderBy

inheritedorHaving

inheritedorWhere

  • orWhere(cond: QBFilterQuery<T>): this
  • orWhere(cond: string, params?: any[]): this
  • Parameters

    Returns this

inheritedreturning

  • Parameters

    Returns this

inheritedselect

  • Parameters

    • fields: Field<T> | Field<T>[]
    • distinct: boolean = false

    Returns SelectQueryBuilder<T, any, any, never>

inheritedsetFlag

  • Parameters

    Returns this

inheritedsetFlushMode

  • Parameters

    Returns this

inheritedsetLockMode

  • setLockMode(mode?: LockMode, tables?: string[]): this
  • Parameters

    • optionalmode: LockMode
    • optionaltables: string[]

    Returns this

inheritedsetLoggerContext

  • Sets logger context for this query builder.


    Parameters

    Returns void

inheritedthen

  • then(onfulfilled?: null | (value: QueryResult<T>) => TResult1 | PromiseLike<TResult1>, onrejected?: null | (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<QueryResult<T>>
  • Provides promise-like interface so we can await the QB instance.


    Parameters

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

        Returns Promise<QueryResult<T>>

      inheritedtoQuery

      • toQuery(): { _sql: Sql; params: readonly unknown[]; sql: string }
      • Returns { _sql: Sql; params: readonly unknown[]; sql: string }

        • _sql: Sql
        • params: readonly unknown[]
        • sql: string

      inheritedtruncate

      inheritedunsetFlag

      • Parameters

        Returns this

      inheritedupdate

      inheritedwhere

      • where(cond: string | QBFilterQuery<T>, params?: any[] | $and | $or, operator?: $and | $or): this
      • Parameters

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

        Returns this

      inheritedwithSchema

      • withSchema(schema?: string): this
      • Parameters

        • optionalschema: string

        Returns this

      inheritedwithSubQuery

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

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

        Returns this