Skip to content

@sourceloop/search-service / Exports / SearchQueryBuilder

Class: SearchQueryBuilder<T>

Type parameters

Name Type
T extends Model

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new SearchQueryBuilder<T>(query, schema?)

Type parameters

Name Type
T extends Model<T>

Parameters

Name Type
query DataObject<SearchQuery>
schema? string

Defined in

services/search-service/src/classes/base/query.builder.ts:46

Properties

_placeholderIndex

Protected _placeholderIndex: number = 0

Defined in

services/search-service/src/classes/base/query.builder.ts:35


baseQueryList

Protected baseQueryList: Query[]

Defined in

services/search-service/src/classes/base/query.builder.ts:29


idType

Protected Optional idType: string = 'uuid'

Defined in

services/search-service/src/classes/base/query.builder.ts:34


limitQuery

Protected limitQuery: string

Defined in

services/search-service/src/classes/base/query.builder.ts:30


modelNameMap

Protected modelNameMap: Map<string, string>

Defined in

services/search-service/src/classes/base/query.builder.ts:36


orderQuery

Protected orderQuery: string

Defined in

services/search-service/src/classes/base/query.builder.ts:31


query

Protected query: DataObject<SearchQuery>

Defined in

services/search-service/src/classes/base/query.builder.ts:32


schema

Protected Optional schema: string

Defined in

services/search-service/src/classes/base/query.builder.ts:33


unionString

Abstract unionString: string

Defined in

services/search-service/src/classes/base/query.builder.ts:56

Accessors

placeholder

Protected get placeholder(): string

Returns

string

Defined in

services/search-service/src/classes/base/query.builder.ts:37

Protected set placeholder(val): void

Parameters

Name Type
val string | number

Returns

void

Defined in

services/search-service/src/classes/base/query.builder.ts:41

Methods

_formatColumnSameInDb

Private _formatColumnSameInDb(modelColumn, dbColumn): string | keyof T

Parameters

Name Type
modelColumn keyof T
dbColumn string

Returns

string | keyof T

Defined in

services/search-service/src/classes/base/query.builder.ts:580


_isQuery

Private _isQuery(query): query is Query

Parameters

Name Type
query ShortHandEqualType | Query

Returns

query is Query

Defined in

services/search-service/src/classes/base/query.builder.ts:576


build

build(models, ignoredColumns?, type?, idType?): Object

Parameters

Name Type
models (typeof Model | SearchableModel<T, typeof Model>)[]
ignoredColumns? Exclude<keyof T, "getId" | "getIdObject" | "toJSON" | "toObject">[]
type? typeof Model
idType? string

Returns

Object

Name Type
params AnyObject | (string | AnyObject)[]
query string

Defined in

services/search-service/src/classes/base/query.builder.ts:58


buildClauseFromExpress

buildClauseFromExpress(values, separator, grouping, getPlaceholder): Query

Parameters

Name Type
values ShortHandEqualType | Query | (ShortHandEqualType | Query)[]
separator string
grouping boolean
getPlaceholder () => string

Returns

Query

Defined in

services/search-service/src/classes/base/query.builder.ts:527


buildColumnValueForExpression

buildColumnValueForExpression(expressionValue, p): any[]

Parameters

Name Type
expressionValue PredicateValueType<ShortHandEqualType>
p PropertyDefinition

Returns

any[]

Defined in

services/search-service/src/classes/base/query.builder.ts:368


buildExpression

buildExpression(columnName, prop, operator, value, model): Object

Parameters

Name Type
columnName keyof T
prop PropertyDefinition
operator string
value ShortHandEqualType | Query | (ShortHandEqualType | Query)[]
model typeof Model

Returns

Object

Name Type
params ShortHandEqualType[]
sql string

Defined in

services/search-service/src/classes/base/query.builder.ts:463


getColumnListFromArray

getColumnListFromArray(model, columns, filter): Object

Parameters

Name Type
model typeof Model
columns keyof T[]
filter keyof T[]

Returns

Object

Name Type
columnList string
selectors string

Defined in

services/search-service/src/classes/base/query.builder.ts:179


getColumnListFromArrayOrMap

getColumnListFromArrayOrMap(model, columns, filter): Object

Parameters

Name Type
model typeof Model
columns keyof T[] | ColumnMap<T>
filter keyof T[]

Returns

Object

Name Type
columnList string
selectors string

Defined in

services/search-service/src/classes/base/query.builder.ts:132


getColumnListFromMap

getColumnListFromMap(model, columns, filter): Object

Parameters

Name Type
model typeof Model
columns ColumnMap<T>
filter keyof T[]

Returns

Object

Name Type
columnList string
selectors string

Defined in

services/search-service/src/classes/base/query.builder.ts:144


getColumnName

getColumnName(model, name): any

Parameters

Name Type
model typeof Model
name keyof T

Returns

any

Defined in

services/search-service/src/classes/base/query.builder.ts:391


getModelName

getModelName(model): string

Parameters

Name Type
model typeof Model

Returns

string

Defined in

services/search-service/src/classes/base/query.builder.ts:571


getSchemaName

getSchemaName(model): string

Parameters

Name Type
model typeof Model

Returns

string

Defined in

services/search-service/src/classes/base/query.builder.ts:567


getTableName

getTableName(model): string

Parameters

Name Type
model typeof Model

Returns

string

Defined in

services/search-service/src/classes/base/query.builder.ts:563


handleAndOr

handleAndOr<S>(where, key, model): undefined | Query

Type parameters

Name Type
S extends typeof Model

Parameters

Name Type
where SearchWhereFilter<AnyObject>
key never
model S

Returns

undefined | Query

Defined in

services/search-service/src/classes/base/query.builder.ts:312


handleKeys

handleKeys(model, key, where): undefined | Query | Queries

Parameters

Name Type
model typeof Model
key never
where SearchWhereFilter<AnyObject>

Returns

undefined | Query | Queries

Defined in

services/search-service/src/classes/base/query.builder.ts:269


handleObjectValue

handleObjectValue<S>(expression, p, key, model): undefined | Query

Type parameters

Name Type
S extends typeof Model

Parameters

Name Type
expression PredicateComparison<ShortHandEqualType>
p PropertyDefinition
key never
model S

Returns

undefined | Query

Defined in

services/search-service/src/classes/base/query.builder.ts:343


limit

limit(): void

Returns

void

Defined in

services/search-service/src/classes/base/query.builder.ts:77


order

order(columns): void

Parameters

Name Type
columns keyof T[]

Returns

void

Defined in

services/search-service/src/classes/base/query.builder.ts:102


paramString

paramString(index): string

Parameters

Name Type
index number

Returns

string

Defined in

services/search-service/src/classes/base/query.builder.ts:208


paramsBuild

paramsBuild(param): AnyObject | (string | AnyObject)[]

Parameters

Name Type
param string

Returns

AnyObject | (string | AnyObject)[]

Defined in

services/search-service/src/classes/base/query.builder.ts:200


parseIdPlaceholder

parseIdPlaceholder(prop): string

Parameters

Name Type
prop PropertyDefinition

Returns

string

Defined in

services/search-service/src/classes/base/query.builder.ts:383


queryBuild

queryBuild(models, ignoredColumns?, type?): string

Parameters

Name Type
models (typeof Model | SearchableModel<T, typeof Model>)[]
ignoredColumns? keyof T[]
type? typeof Model

Returns

string

Defined in

services/search-service/src/classes/base/query.builder.ts:212


Abstract search(model, columns, ignoredColumns): void

Parameters

Name Type
model typeof Model
columns keyof T[] | ColumnMap<T>
ignoredColumns keyof T[]

Returns

void

Defined in

services/search-service/src/classes/base/query.builder.ts:50


toArrayPropTypes

toArrayPropTypes<R>(prop, val): any

Type parameters

Name
R

Parameters

Name Type
prop PropertyDefinition
val R | R[]

Returns

any

Defined in

services/search-service/src/classes/base/query.builder.ts:447


toColumnValue

toColumnValue(prop, val): any

Parameters

Name Type
prop PropertyDefinition
val PredicateValueType<ShortHandEqualType>

Returns

any

Defined in

services/search-service/src/classes/base/query.builder.ts:398


toDateType

toDateType(val): Object

Parameters

Name Type
val string | Date

Returns

Object

Name Type
params string[]
sql string

Defined in

services/search-service/src/classes/base/query.builder.ts:434


whereBuild

whereBuild<S>(model, where?): Object

Type parameters

Name Type
S extends typeof Model

Parameters

Name Type
model S
where? SearchWhereFilter<AnyObject>

Returns

Object

Name Type
params ShortHandEqualType[]
sql string

Defined in

services/search-service/src/classes/base/query.builder.ts:255