Skip to content

@istock/iswork / Exports / QueryBuilder

Class: QueryBuilder

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new QueryBuilder(params?): QueryBuilder

Parameters

NameTypeDescription
params?string | IQueryParamsOptions查询字符串

Returns

QueryBuilder

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

TQueryBuilderOptions

Defined in

src/packages/iswork/src/orm/query-builder.ts:140

Methods

#assertNestCond

#assertNestCond<Type>(v): v is Type

判断是否是嵌套条件

Type parameters

NameType
Typeunknown

Parameters

NameType
vunknown

Returns

v is Type

Defined in

src/packages/iswork/src/orm/query-builder.ts:412


#cond

#cond(f, _cond?): TQueryFilter

添加查询条件及校验

Parameters

NameTypeDefault value
fTQueryFilter | TQueryFilterArrundefined
_cond"search" | "filter" | "or"'search'

Returns

TQueryFilter

Defined in

src/packages/iswork/src/orm/query-builder.ts:323


#createFromParams

#createFromParams(params): this

根据参数对象设置对象值

Parameters

NameType
paramsIQueryParamsOptions

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:300


#parseJoin

#parseJoin(j): TQueryJoin

解析联表查询条件及校验

Parameters

NameType
jTQueryJoin | TQueryJoinArr

Returns

TQueryJoin

Defined in

src/packages/iswork/src/orm/query-builder.ts:343


#parseSortBy

#parseSortBy(s): TQuerySort

添加排序及校验

Parameters

NameType
sTQuerySort | TQuerySortArr

Returns

TQuerySort

Defined in

src/packages/iswork/src/orm/query-builder.ts:359


#setCondition

#setCondition(f, cond): void

设置条件方法

Parameters

NameType
fTQueryFilter | 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

NameType
nnumber
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

NameTypeDefault valueDescription
encodebooleantrue是否编码

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(s): QueryBuilder

设置搜索条件

Parameters

NameType
sTSCondition

Returns

QueryBuilder

Defined in

src/packages/iswork/src/orm/query-builder.ts:194


select

select(fields): this

选择字段

Parameters

NameTypeDescription
fieldsTQueryFields数组字段名

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:180


setFilter

setFilter(f): this

设置过滤

Parameters

NameTypeDescription
fTQueryFilter | TQueryFilterArr | (TQueryFilter | TQueryFilterArr)[]过滤条件

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:205


setIncludeDeleted

setIncludeDeleted(n): this

Parameters

NameType
nnumber

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:290


setJoin

setJoin(j): this

设置联表查询

Parameters

NameTypeDescription
jTQueryJoin | TQueryJoinArr | (TQueryJoin | TQueryJoinArr)[]联表查询选项

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:223


setLimit

setLimit(n): this

设置数据数量限制

Parameters

NameType
nnumber

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:259


setOffset

setOffset(n): this

设置数据起始位置

Parameters

NameType
nnumber

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:268


setOr

setOr(f): this

设置或逻辑

Parameters

NameTypeDescription
fTQueryFilter | TQueryFilterArr | (TQueryFilter | TQueryFilterArr)[]过滤条件

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:214


setPage

setPage(n): this

设置页码

Parameters

NameType
nnumber

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:277


sortBy

sortBy(s): this

设置排序

Parameters

NameTypeDescription
sTQuerySort | TQuerySortArr | (TQuerySort | TQuerySortArr)[]排序参数条件

Returns

this

Defined in

src/packages/iswork/src/orm/query-builder.ts:241


create

create(params?): QueryBuilder

QueryBuilder工厂方法,创建一个QueryBuilder实例

Parameters

NameTypeDescription
params?string | IQueryParamsOptions查询参数选项

Returns

QueryBuilder

Defined in

src/packages/iswork/src/orm/query-builder.ts:128


getOptions

getOptions(): IPartialQueryBuilderOptions

获取参数

Returns

IPartialQueryBuilderOptions

IPartialQueryBuilderOptions QueryBuilder选项

Defined in

src/packages/iswork/src/orm/query-builder.ts:120


setOptions

setOptions(options): void

设置参数

Parameters

NameTypeDescription
optionsIPartialQueryBuilderOptionsQueryBuilder选项

Returns

void

Defined in

src/packages/iswork/src/orm/query-builder.ts:105

免责声明:本站所有信息、数据、软件仅供学习研究,都不构成投资建议,本站不承担由此导致的任何责任。