TruncateQueryBuilder <T>
Hierarchy
- RunQueryBuilder<T>
- TruncateQueryBuilder
Index
Properties
Methods
- addSelect
- 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
- orWhere
- orderBy
- returning
- select
- setFlag
- setFlushMode
- setLockMode
- setLoggerContext
- then
- toQuery
- truncate
- unsetFlag
- update
- where
- withSchema
- withSubQuery
Properties
alias
helper
mainAlias
Methods
addSelect
Parameters
Returns SelectQueryBuilder<T, any, any, never>
andWhere
Parameters
cond: QBFilterQuery<T>
Returns this
applyFilters
Parameters
filterOptions: boolean | string[] | Dictionary<boolean | Dictionary> = {}
Returns Promise<QueryBuilder<T, any, any, never>>
as
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>
cache
Parameters
config: number | boolean | [string, number] = true
Returns this
clone
Parameters
optionalreset: boolean | string[]
Returns QueryBuilder<T, never, never, never>
comment
Prepend comment to the sql query using the syntax
/* ... *‍/
. Some characters are forbidden such as/*, *‍/
and?
.Parameters
comment: string | string[]
Returns this
count
Parameters
optionalfield: string | string[]
distinct: boolean = false
Returns CountQueryBuilder<T>
delete
Parameters
optionalcond: QBFilterQuery
Returns DeleteQueryBuilder<T>
distinct
Returns SelectQueryBuilder<T, any, any, never>
distinctOn
postgres only
Parameters
fields: string | string[]
Returns SelectQueryBuilder<T, any, any, never>
execute
Type parameters
- Result = QueryResult<T>
Parameters
optionalmethod: get | all | run
optionalmapResults: boolean
Returns Promise<Result>
from
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.
Type parameters
- Entity: Partial<Entity> = Partial<any>
Parameters
target: QueryBuilder<Entity, never, never, never>
optionalaliasName: string
Returns SelectQueryBuilder<Entity, any, any, never>
getCount
Executes count query (without offset and limit), returning total count of results
Parameters
optionalfield: string | string[]
optionaldistinct: boolean
Returns Promise<number>
getFormattedQuery
Returns raw interpolated query string with all the parameters inlined.
Returns string
getKnex
Parameters
processVirtualEntity: boolean = true
Returns QueryBuilder<any, any>
getKnexQuery
Parameters
processVirtualEntity: boolean = true
Returns QueryBuilder<any, any>
getLoggerContext
Gets logger context for this query builder.
Type parameters
- T: Dictionary & LoggingOptions = Dictionary
Returns T
getParams
Returns the list of all parameters for this query.
Returns readonly Value[]
getQuery
Returns the query with parameters as wildcards.
Returns string
getResultAndCount
Executes the query, returning both array of results and total count query (without offset and limit).
Returns Promise<[T[], number]>
groupBy
Parameters
fields: string | keyof T | readonly (string | keyof T)[]
Returns SelectQueryBuilder<T, any, any, never>
hasFlag
Parameters
flag: QueryFlag
Returns boolean
having
Parameters
cond: string | QBFilterQuery = {}
optionalparams: any[]
Returns SelectQueryBuilder<T, any, any, never>
hintComment
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
ignore
Returns this
indexHint
Adds index hint to the FROM clause.
Parameters
sql: string
Returns this
innerJoin
Type parameters
- Field: string | AnyString
- Alias: string
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] }>
innerJoinAndSelect
Type parameters
- Field: string | AnyString
- Alias: string
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] }>
innerJoinLateral
Parameters
field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>
alias: string
cond: QBFilterQuery = {}
optionalschema: string
Returns this
innerJoinLateralAndSelect
Type parameters
- Field: string | AnyString
- Alias: string
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] }>
insert
Parameters
data: RequiredEntityData<T> | RequiredEntityData<T>[]
Returns InsertQueryBuilder<T>
join
Type parameters
- Field: string | AnyString
- Alias: string
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] }>
joinAndSelect
Type parameters
- Field: string | AnyString
- Alias: string
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] }>
leftJoin
Type parameters
- Field: string | AnyString
- Alias: string
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] }>
leftJoinAndSelect
Type parameters
- Field: string | AnyString
- Alias: string
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] }>
leftJoinLateral
Parameters
field: QueryBuilder<any, any> | QueryBuilder<any, never, never, never>
alias: string
cond: QBFilterQuery = {}
optionalschema: string
Returns this
leftJoinLateralAndSelect
Type parameters
- Field: string | AnyString
- Alias: string
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] }>
limit
Parameters
optionallimit: number
offset: number = 0
Returns SelectQueryBuilder<T, any, any, never>
merge
Parameters
optionaldata: Field<T>[] | EntityData<T>
Returns this
offset
Parameters
optionaloffset: number
Returns SelectQueryBuilder<T, any, any, never>
onConflict
Parameters
Returns InsertQueryBuilder<T>
orWhere
Parameters
cond: QBFilterQuery<T>
Returns this
orderBy
Parameters
orderBy: QBQueryOrderMap<T> | QBQueryOrderMap<T>[]
Returns SelectQueryBuilder<T, any, any, never>
returning
select
Parameters
Returns SelectQueryBuilder<T, any, any, never>
setFlag
Parameters
flag: QueryFlag
Returns this
setFlushMode
Parameters
optionalflushMode: FlushMode
Returns this
setLockMode
Parameters
optionalmode: LockMode
optionaltables: string[]
Returns this
setLoggerContext
Sets logger context for this query builder.
Parameters
context: LoggingOptions & Dictionary
Returns void
then
Type parameters
- TResult1 = QueryResult<T>
- TResult2 = never
Parameters
optionalonfulfilled: null | (value: QueryResult<T>) => TResult1 | PromiseLike<TResult1>
optionalonrejected: null | (reason: any) => TResult2 | PromiseLike<TResult2>
Returns Promise<QueryResult<T>>
toQuery
Returns { _sql: Sql; params: readonly unknown[]; sql: string }
_sql: Sql
params: readonly unknown[]
sql: string
truncate
Returns TruncateQueryBuilder<T>
unsetFlag
Parameters
flag: QueryFlag
Returns this
update
Parameters
data: EntityData<T>
Returns UpdateQueryBuilder<T>
where
Parameters
cond: string | QBFilterQuery<T>
optionalparams: any[] | $and | $or
optionaloperator: $and | $or
Returns this
withSchema
Parameters
optionalschema: string
Returns this
withSubQuery
Parameters
subQuery: QueryBuilder<any, any>
alias: string
Returns this
Apply filters to the QB where condition.