Expression
Expression is used to build filtering expressions, like those used in WHERE clauses. It can be used for fluent and safe building of queries using untrusted input.
Example:
e => e
.field('host').equals.value('ares.peet.io')
.or
.field('host').matches(/example\.com$/)
.or
.expr(e => e
.field('country').equals.value('US')
.and
.field('state').equals.value('WA'));
// Generates:
// "host" = 'ares.peet.io' OR "host" ~= /example\.com$/ OR \
// ("county" = 'US' AND "state" = 'WA')
Member Summary
Public Members | ||
public get |
and: * Chains on an AND clause to the expression. |
|
public get |
div: * Chains on a |
|
public get |
doesntMatch: * Chains on a |
|
public get |
equals: * Chains on a |
|
public get |
gt: * Chains on a |
|
public get |
gte: * Chains on a |
|
public get |
lt: * Chains on a |
|
public get |
lte: * Chains on a |
|
public get |
matches: * Chains on a |
|
public get |
minus: * Chains on a |
|
public get |
notEqual: * Chains on a |
|
public get |
or: * Chains on an OR clause to the expression. |
|
public get |
plus: * Chains on a |
|
public get |
times: * Chains on a |
Method Summary
Public Methods | ||
public |
exp(fn: *): * Inserts a subexpression; invokes the function with a new expression that can be chained on. |
|
public |
field(name: *): * Inserts a field reference into the expression; the name will be automatically escaped. |
|
public |
tag(name: *): * Inserts a tag reference into the expression; the name will be automatically escaped. |
|
public |
toString(): * Converts the expression into its InfluxQL representation. |
|
public |
value(value: *): * Value chains on a value to the expression. |
Public Members
Public Methods
public exp(fn: *): * source
Inserts a subexpression; invokes the function with a new expression that can be chained on.
Params:
Name | Type | Attribute | Description |
fn | * |
Return:
* |
Example:
e.field('a').equals.value('b')
.or.expr(e =>
e.field('b').equals.value('b')
.and.field('a').equals.value('c'))
.toString()
// "a" = 'b' OR ("b" = 'b' AND "a" = 'c')
public field(name: *): * source
Inserts a field reference into the expression; the name will be automatically escaped.
Params:
Name | Type | Attribute | Description |
name | * |
Return:
* |
public tag(name: *): * source
Inserts a tag reference into the expression; the name will be automatically escaped.
Params:
Name | Type | Attribute | Description |
name | * |
Return:
* |
public value(value: *): * source
Value chains on a value to the expression.
- Numbers will be inserted verbatim
- Strings will be escaped and inserted
- Booleans will be inserted correctly
- Dates will be formatted and inserted correctly, including INanoDates.
- Regular expressions will be inserted correctly, however an error will be thrown if they contain flags, as regex flags do not work in Influx
- Otherwise we'll try to call
.toString()
on the value, throwing if we cannot do so.
Params:
Name | Type | Attribute | Description |
value | * |
Return:
* |