Skip to content

Latest commit

 

History

History
410 lines (226 loc) · 10 KB

File metadata and controls

410 lines (226 loc) · 10 KB

@onzag/itemize / Modules / database/base / ConditionalBuilder

Class: ConditionalBuilder

database/base.ConditionalBuilder

The conditional builder class is based on the query builder and its an utility to create conditional based queries like the where query, joins queries, etc... whatever is using boolean conditions

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new ConditionalBuilder(parent?, type): ConditionalBuilder

Build a new conditional builder

Parameters

Name Type Default value Description
parent ConditionalBuilder null the parent of it
type string undefined the type, WHERE, ON, etc... it will be used

Returns

ConditionalBuilder

Overrides

QueryBuilder.constructor

Defined in

database/base.ts:248

Properties

conditions

Private conditions: IConditionalBuilderConditionType[] = []

This is the list of conditions, it represents either a expression or a subcondition with a gate included, and or or

Defined in

database/base.ts:231


parent

Private parent: ConditionalBuilder

The parent of the condition, they might compile different since these conditions nest

Defined in

database/base.ts:236


type

type: string

The type of the condition, WHERE, ON, etc... whatever you fancy

Defined in

database/base.ts:241

Methods

addBindingSource

addBindingSource(value): void

Adds a binding source to the binding source list in order

Parameters

Name Type Description
value ExtendedBindingType the binding source to add

Returns

void

Inherited from

QueryBuilder.addBindingSource

Defined in

database/base.ts:69


addBindingSources

addBindingSources(values): void

Adds many binding sources to the bindings sources list

Parameters

Name Type Description
values ExtendedBindingType[] the binding sources to add

Returns

void

Inherited from

QueryBuilder.addBindingSources

Defined in

database/base.ts:77


clear

clear(): ConditionalBuilder

Clears the conditional builder

Returns

ConditionalBuilder

itself

Defined in

database/base.ts:352


clearBindingSources

clearBindingSources(): void

Removes all binding sources

Returns

void

Inherited from

QueryBuilder.clearBindingSources

Defined in

database/base.ts:105


compile

compile(): string

Compiles the condition

Returns

string

a string that represents the condition

Overrides

QueryBuilder.compile

Defined in

database/base.ts:362


condition

condition(gate, prefix, rule, bindings?): ConditionalBuilder

Makes a new condition based on an expression or a subrule function

Parameters

Name Type Description
gate "AND" | "OR" the gate to use
prefix string an optional prefix to the rule, if none, make it null
rule string | QueryBuilder | ConditionalBuilderFn<any> either the expression itself or a subcondition
bindings? BasicBindingType[] the bindings for the expression, will not be used if using a subcondition

Returns

ConditionalBuilder

itself

Defined in

database/base.ts:291


getBindings

getBindings(): BasicBindingType[]

Provides the bindings for the query in order that should match the compilation

Returns

BasicBindingType[]

a list of basic bindings

Inherited from

QueryBuilder.getBindings

Defined in

database/base.ts:168


hasRulesAssigned

hasRulesAssigned(): boolean

Specifies whether the builder has conditions whatsoever

Returns

boolean

Defined in

database/base.ts:259


popBindingSource

popBindingSource(): ExtendedBindingType

Removes the last added biding source and returns it

Returns

ExtendedBindingType

Inherited from

QueryBuilder.popBindingSource

Defined in

database/base.ts:112


shiftBindingSource

shiftBindingSource(value): void

Adds a binding source at the start of the bindings source list

Parameters

Name Type Description
value ExtendedBindingType the binding source to add

Returns

void

Inherited from

QueryBuilder.shiftBindingSource

Defined in

database/base.ts:89


shiftBindingSources

shiftBindingSources(values): void

Adds many binding sources at the start of the bindings source list

Parameters

Name Type Description
values ExtendedBindingType[] the binding sources to add

Returns

void

Inherited from

QueryBuilder.shiftBindingSources

Defined in

database/base.ts:98


subcondition

subcondition(): ConditionalBuilder

It should provide a new conditional builder that should be a child of this

Returns

ConditionalBuilder

a new builder for itself to make a child of

Defined in

database/base.ts:277


toSQL

toSQL(): IQueryBuilderSQLResult

Returns the SQL result for usage in the query builder

Returns

IQueryBuilderSQLResult

a sql builder result with the bindings and the query itself

Inherited from

QueryBuilder.toSQL

Defined in

database/base.ts:129