InsertQueryBuilder <T>
Hierarchy
- RunQueryBuilder<T>
- InsertQueryBuilder
Index
Properties
Methods
- addSelect
- andHaving
- andWhere
- applyFilters
- as
- cache
- clone
- comment
- count
- delete
- distinct
- distinctOn
- execute
- from
- getCount
- getFormattedQuery
- getKnex
- getKnexQuery
- getLoggerContext
- getParams
- getQuery
- getResultAndCount
- groupBy
- hasFlag
- having
- hintComment
- ignore
- indexHint
- innerJoin
- innerJoinAndSelect
- innerJoinLateral
- innerJoinLateralAndSelect
- insert
- join
- joinAndSelect
- leftJoin
- leftJoinAndSelect
- leftJoinLateral
- leftJoinLateralAndSelect
- limit
- merge
- offset
- onConflict
- orderBy
- orHaving
- orWhere
- returning
- select
- setFlag
- setFlushMode
- setLockMode
- setLoggerContext
- then
- toQuery
- truncate
- unsetFlag
- update
- where
- withSchema
- withSubQuery
Properties
inheritedalias
inheritedhelper
inheritedmainAlias
Methods
inheritedaddSelect
Parameters
Returns SelectQueryBuilder<T, any, any, never>
inheritedandHaving
Parameters
optionalcond: string | QBFilterQuery
optionalparams: any[]
Returns SelectQueryBuilder<T, any, any, never>
inheritedandWhere
Parameters
cond: QBFilterQuery<T>
Returns this
inheritedapplyFilters
Parameters
filterOptions: boolean | string[] | Dictionary<boolean | Dictionary> = {}
Returns Promise<void>
inheritedas
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 metadataParameters
alias: string
Returns QueryBuilder<any, any>
inheritedcache
Parameters
config: number | boolean | [string, number] = true
Returns this
inheritedclone
Parameters
optionalreset: boolean | string[]
Returns QueryBuilder<T, never, never, never>
inheritedcomment
Prepend comment to the sql query using the syntax
/* ... *‍/
. Some characters are forbidden such as/*, *‍/
and?
.Parameters
comment: string | string[]
Returns this
inheritedcount
Parameters
optionalfield: EntityKeyOrString<T> | EntityKeyOrString<T>[]
distinct: boolean = false
Returns CountQueryBuilder<T>
inheriteddelete
Parameters
optionalcond: QBFilterQuery
Returns DeleteQueryBuilder<T>
inheriteddistinct
Returns SelectQueryBuilder<T, any, any, never>
inheriteddistinctOn
postgres only
Parameters
fields: EntityKeyOrString<T> | EntityKeyOrString<T>[]
Returns SelectQueryBuilder<T, any, any, never>
inheritedexecute
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
Executes count query (without offset and limit), returning total count of results
Parameters
optionalfield: EntityKeyOrString<T> | EntityKeyOrString<T>[]
optionaldistinct: boolean
Returns Promise<number>
inheritedgetFormattedQuery
Returns raw interpolated query string with all the parameters inlined.
Returns string
inheritedgetKnex
Parameters
processVirtualEntity: boolean = true
Returns QueryBuilder<any, any>
inheritedgetKnexQuery
Parameters
processVirtualEntity: boolean = true
Returns QueryBuilder<any, any>
inheritedgetLoggerContext
Gets logger context for this query builder.
Returns T
inheritedgetParams
Returns the list of all parameters for this query.
Returns readonly Value[]
inheritedgetQuery
Returns the query with parameters as wildcards.
Returns string
inheritedgetResultAndCount
Executes the query, returning both array of results and total count query (without offset and limit).
Returns Promise<[T[], number]>
inheritedgroupBy
Parameters
fields: EntityKeyOrString<T> | readonly EntityKeyOrString<T>[]
Returns SelectQueryBuilder<T, any, any, never>
inheritedhasFlag
Parameters
flag: QueryFlag
Returns boolean
inheritedhaving
Parameters
cond: string | QBFilterQuery = {}
optionalparams: any[]
optionaloperator: $and | $or
Returns SelectQueryBuilder<T, any, any, never>
inheritedhintComment
Add hints to the query using comment-like syntax
/*+ ... *‍/
. 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
Returns this
inheritedindexHint
Adds index hint to the FROM clause.
Parameters
sql: string
Returns this
inheritedinnerJoin
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
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
Parameters
field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>
alias: string
cond: QBFilterQuery = {}
optionalschema: string
Returns this
inheritedinnerJoinLateralAndSelect
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
Parameters
data: RequiredEntityData<T> | RequiredEntityData<T>[]
Returns InsertQueryBuilder<T>
inheritedjoin
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
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
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
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
Parameters
field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>
alias: string
cond: QBFilterQuery = {}
optionalschema: string
Returns this
inheritedleftJoinLateralAndSelect
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
optionaldata: Field<T>[] | EntityData<T>
Returns this
inheritedoffset
Parameters
optionaloffset: number
Returns SelectQueryBuilder<T, any, any, never>
inheritedonConflict
Parameters
Returns InsertQueryBuilder<T>
inheritedorderBy
Parameters
orderBy: QBQueryOrderMap<T> | QBQueryOrderMap<T>[]
Returns SelectQueryBuilder<T, any, any, never>
inheritedorHaving
Parameters
optionalcond: string | QBFilterQuery
optionalparams: any[]
Returns SelectQueryBuilder<T, any, any, never>
inheritedorWhere
Parameters
cond: QBFilterQuery<T>
Returns this
inheritedreturning
inheritedselect
Parameters
Returns SelectQueryBuilder<T, any, any, never>
inheritedsetFlag
Parameters
flag: QueryFlag
Returns this
inheritedsetFlushMode
Parameters
optionalflushMode: FlushMode
Returns this
inheritedsetLockMode
Parameters
optionalmode: LockMode
optionaltables: string[]
Returns this
inheritedsetLoggerContext
Sets logger context for this query builder.
Parameters
context: LoggingOptions & Dictionary
Returns void
inheritedthen
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
Returns { _sql: Sql; params: readonly unknown[]; sql: string }
_sql: Sql
params: readonly unknown[]
sql: string
inheritedtruncate
Returns TruncateQueryBuilder<T>
inheritedunsetFlag
Parameters
flag: QueryFlag
Returns this
inheritedupdate
Parameters
data: EntityData<T>
Returns UpdateQueryBuilder<T>
inheritedwhere
Parameters
cond: string | QBFilterQuery<T>
optionalparams: any[] | $and | $or
optionaloperator: $and | $or
Returns this
inheritedwithSchema
Parameters
optionalschema: string
Returns this
inheritedwithSubQuery
Parameters
subQuery: QueryBuilder<any, any>
alias: string
Returns this
Apply filters to the QB where condition.