@istock/iswork / Exports / QueryBuilder
Class: QueryBuilder
Table of contents
Constructors
Properties
Accessors
Methods
- #assertNestCond
- #cond
- #createFromParams
- #parseJoin
- #parseSortBy
- #setCondition
- #setNumeric
- getQueryData
- query
- resetCache
- search
- select
- setFilter
- setIncludeDeleted
- setJoin
- setLimit
- setOffset
- setOr
- setPage
- sortBy
- create
- getOptions
- setOptions
Constructors
constructor
• new QueryBuilder(params?
): QueryBuilder
Parameters
Name | Type | Description |
---|---|---|
params? | string | IQueryParamsOptions | 查询字符串 |
Returns
Defined in
src/packages/iswork/src/orm/query-builder.ts:147
Properties
#queryObject
• Private
#queryObject: Partial
<IParsedRequestParams
> = {}
Defined in
src/packages/iswork/src/orm/query-builder.ts:135
#queryString
• Private
#queryString: string
= ''
Defined in
src/packages/iswork/src/orm/query-builder.ts:133
#options
▪ Static
Private
#options: TQueryBuilderOptions
Defined in
src/packages/iswork/src/orm/query-builder.ts:83
Accessors
options
• get
options(): TQueryBuilderOptions
获取参数
Returns
Defined in
src/packages/iswork/src/orm/query-builder.ts:140
Methods
#assertNestCond
▸ #assertNestCond<Type
>(v
): v is Type
判断是否是嵌套条件
Type parameters
Name | Type |
---|---|
Type | unknown |
Parameters
Name | Type |
---|---|
v | unknown |
Returns
v is Type
Defined in
src/packages/iswork/src/orm/query-builder.ts:412
#cond
▸ #cond(f
, _cond?
): TQueryFilter
添加查询条件及校验
Parameters
Name | Type | Default value |
---|---|---|
f | TQueryFilter | TQueryFilterArr | undefined |
_cond | "search" | "filter" | "or" | 'search' |
Returns
Defined in
src/packages/iswork/src/orm/query-builder.ts:323
#createFromParams
▸ #createFromParams(params
): this
根据参数对象设置对象值
Parameters
Name | Type |
---|---|
params | IQueryParamsOptions |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:300
#parseJoin
▸ #parseJoin(j
): TQueryJoin
解析联表查询条件及校验
Parameters
Name | Type |
---|---|
j | TQueryJoin | TQueryJoinArr |
Returns
Defined in
src/packages/iswork/src/orm/query-builder.ts:343
#parseSortBy
▸ #parseSortBy(s
): TQuerySort
添加排序及校验
Parameters
Name | Type |
---|---|
s | TQuerySort | TQuerySortArr |
Returns
Defined in
src/packages/iswork/src/orm/query-builder.ts:359
#setCondition
▸ #setCondition(f
, cond
): void
设置条件方法
Parameters
Name | Type |
---|---|
f | TQueryFilter | TQueryFilterArr | (TQueryFilter | TQueryFilterArr )[] |
cond | "filter" | "or" |
Returns
void
Defined in
src/packages/iswork/src/orm/query-builder.ts:376
#setNumeric
▸ #setNumeric(n
, cond
): void
设置数字方法及校验
Parameters
Name | Type |
---|---|
n | number |
cond | "limit" | "offset" | "page" | "cache" | "includeDeleted" |
Returns
void
Defined in
src/packages/iswork/src/orm/query-builder.ts:398
getQueryData
▸ getQueryData(): Partial
<IParsedRequestParams
>
获取查询对象数据
Returns
Partial
<IParsedRequestParams
>
Defined in
src/packages/iswork/src/orm/query-builder.ts:172
query
▸ query(encode?
): string
获取query查询字符串
Parameters
Name | Type | Default value | Description |
---|---|---|---|
encode | boolean | true | 是否编码 |
Returns
string
Defined in
src/packages/iswork/src/orm/query-builder.ts:160
resetCache
▸ resetCache(): this
重置cache功能
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:285
search
▸ search(s
): QueryBuilder
设置搜索条件
Parameters
Name | Type |
---|---|
s | TSCondition |
Returns
Defined in
src/packages/iswork/src/orm/query-builder.ts:194
select
▸ select(fields
): this
选择字段
Parameters
Name | Type | Description |
---|---|---|
fields | TQueryFields | 数组字段名 |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:180
setFilter
▸ setFilter(f
): this
设置过滤
Parameters
Name | Type | Description |
---|---|---|
f | TQueryFilter | TQueryFilterArr | (TQueryFilter | TQueryFilterArr )[] | 过滤条件 |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:205
setIncludeDeleted
▸ setIncludeDeleted(n
): this
Parameters
Name | Type |
---|---|
n | number |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:290
setJoin
▸ setJoin(j
): this
设置联表查询
Parameters
Name | Type | Description |
---|---|---|
j | TQueryJoin | TQueryJoinArr | (TQueryJoin | TQueryJoinArr )[] | 联表查询选项 |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:223
setLimit
▸ setLimit(n
): this
设置数据数量限制
Parameters
Name | Type |
---|---|
n | number |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:259
setOffset
▸ setOffset(n
): this
设置数据起始位置
Parameters
Name | Type |
---|---|
n | number |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:268
setOr
▸ setOr(f
): this
设置或逻辑
Parameters
Name | Type | Description |
---|---|---|
f | TQueryFilter | TQueryFilterArr | (TQueryFilter | TQueryFilterArr )[] | 过滤条件 |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:214
setPage
▸ setPage(n
): this
设置页码
Parameters
Name | Type |
---|---|
n | number |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:277
sortBy
▸ sortBy(s
): this
设置排序
Parameters
Name | Type | Description |
---|---|---|
s | TQuerySort | TQuerySortArr | (TQuerySort | TQuerySortArr )[] | 排序参数条件 |
Returns
this
Defined in
src/packages/iswork/src/orm/query-builder.ts:241
create
▸ create(params?
): QueryBuilder
QueryBuilder工厂方法,创建一个QueryBuilder实例
Parameters
Name | Type | Description |
---|---|---|
params? | string | IQueryParamsOptions | 查询参数选项 |
Returns
Defined in
src/packages/iswork/src/orm/query-builder.ts:128
getOptions
▸ getOptions(): IPartialQueryBuilderOptions
获取参数
Returns
IPartialQueryBuilderOptions QueryBuilder选项
Defined in
src/packages/iswork/src/orm/query-builder.ts:120
setOptions
▸ setOptions(options
): void
设置参数
Parameters
Name | Type | Description |
---|---|---|
options | IPartialQueryBuilderOptions | QueryBuilder选项 |
Returns
void
Defined in
src/packages/iswork/src/orm/query-builder.ts:105