@onzag/itemize / Modules / database/base / 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
-
↳
ConditionalBuilder↳↳
WhereBuilder
- addBindingSource
- addBindingSources
- clear
- clearBindingSources
- compile
- condition
- getBindings
- hasRulesAssigned
- popBindingSource
- shiftBindingSource
- shiftBindingSources
- subcondition
- toSQL
• new ConditionalBuilder(parent?, type): ConditionalBuilder
Build a new conditional builder
| Name | Type | Default value | Description |
|---|---|---|---|
parent |
ConditionalBuilder |
null |
the parent of it |
type |
string |
undefined |
the type, WHERE, ON, etc... it will be used |
• Private conditions: IConditionalBuilderConditionType[] = []
This is the list of conditions, it represents either a expression or a subcondition with a gate included, and or or
• Private parent: ConditionalBuilder
The parent of the condition, they might compile different since these conditions nest
• type: string
The type of the condition, WHERE, ON, etc... whatever you fancy
▸ addBindingSource(value): void
Adds a binding source to the binding source list in order
| Name | Type | Description |
|---|---|---|
value |
ExtendedBindingType |
the binding source to add |
void
▸ addBindingSources(values): void
Adds many binding sources to the bindings sources list
| Name | Type | Description |
|---|---|---|
values |
ExtendedBindingType[] |
the binding sources to add |
void
QueryBuilder.addBindingSources
▸ clear(): ConditionalBuilder
Clears the conditional builder
itself
▸ clearBindingSources(): void
Removes all binding sources
void
QueryBuilder.clearBindingSources
▸ compile(): string
Compiles the condition
string
a string that represents the condition
▸ condition(gate, prefix, rule, bindings?): ConditionalBuilder
Makes a new condition based on an expression or a subrule function
| 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 |
itself
▸ getBindings(): BasicBindingType[]
Provides the bindings for the query in order that should match the compilation
a list of basic bindings
▸ hasRulesAssigned(): boolean
Specifies whether the builder has conditions whatsoever
boolean
▸ popBindingSource(): ExtendedBindingType
Removes the last added biding source and returns it
▸ shiftBindingSource(value): void
Adds a binding source at the start of the bindings source list
| Name | Type | Description |
|---|---|---|
value |
ExtendedBindingType |
the binding source to add |
void
QueryBuilder.shiftBindingSource
▸ shiftBindingSources(values): void
Adds many binding sources at the start of the bindings source list
| Name | Type | Description |
|---|---|---|
values |
ExtendedBindingType[] |
the binding sources to add |
void
QueryBuilder.shiftBindingSources
▸ subcondition(): ConditionalBuilder
It should provide a new conditional builder that should be a child of this
a new builder for itself to make a child of
▸ toSQL(): IQueryBuilderSQLResult
Returns the SQL result for usage in the query builder
IQueryBuilderSQLResult
a sql builder result with the bindings and the query itself