Constructor
new ODataFilterBuilder(conditionopt) → {ODataFilterBuilder}
Creates a new ODataFilterBuilder instance.
Can be used without "new" operator.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
condition |
string |
<optional> |
'and' | base condition ('and' OR 'or'). |
- Source:
- See:
-
- OData URL Conventions for further information.
Returns:
The ODataFilterBuilder instance.
- Type
- ODataFilterBuilder
Examples
// use short name as alias
const f = ODataFilterBuilder;
// can be used without "new" operator
// default base condition is 'and'
f()
.eq('TypeId', '1')
.eq('SubType/Id', '1')
.toString();
// returns `(TypeId eq '1') and (SubType/Id eq 1)`
// 'or' condition as base condition
f('or')
.eq('TypeId', '1')
.eq('SubType/Id', '1')
.toString();
// returns `(TypeId eq '1') or (SubType/Id eq 1)`
Namespaces
Methods
(static) and() → {ODataFilterBuilder}
Creates new ODataFilterBuilder instance with 'and' as base condition
- Source:
Returns:
The ODataFilterBuilder instance with 'and' as base condition
- Type
- ODataFilterBuilder
Example
f.and()
.eq('a', 1)
.eq('b', 2)
.toString();
// (a eq 1) and (b eq 2)
(static) or() → {ODataFilterBuilder}
Create new ODataFilterBuilder with 'or' as base condition
- Source:
Returns:
The ODataFilterBuilder instance with 'or' as base condition
- Type
- ODataFilterBuilder
Example
f.or()
.eq('a', 1)
.eq('b', 2)
.toString();
// (a eq 1) or (b eq 2)
and(rule) → {ODataFilterBuilder}
Logical And
Parameters:
Name | Type | Description |
---|---|---|
rule |
ODataFilterBuilder~InputRule | Rule to add |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
contains(field, value) → {ODataFilterBuilder}
The contains function returns true if the second parameter string value is a substring of the first parameter string value.
Parameters:
Name | Type | Description |
---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare |
value |
string | Value to compare |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
Example
// return contains(CompanyName, 'Alfreds')
endsWith(field, value) → {ODataFilterBuilder}
The endswith function returns true if the first parameter string value ends with the second parameter string value.
Parameters:
Name | Type | Description |
---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare |
value |
string | Value to compare |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
Example
// return endswith(CompanyName,'Futterkiste')
eq(field, value, normaliseValueopt) → {ODataFilterBuilder}
Equal
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare | ||
value |
string | number | * | A value to compare with | ||
normaliseValue |
boolean |
<optional> |
true | Convert string "value" to "'value'" or not. (Convert by default) |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
ge(field, value, normaliseValueopt) → {ODataFilterBuilder}
Greater than or Equal
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare | ||
value |
string | number | * | A value to compare with | ||
normaliseValue |
boolean |
<optional> |
true | Convert string "value" to "'value'" or not. (Convert by default) |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
gt(field, value, normaliseValueopt) → {ODataFilterBuilder}
Greater Than
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare | ||
value |
string | number | * | A value to compare with | ||
normaliseValue |
boolean |
<optional> |
true | Convert string "value" to "'value'" or not. (Convert by default) |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
in(field, values, normaliseValuesopt) → {ODataFilterBuilder}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare | ||
values |
Array.<string> | string | Values to compare with | ||
normaliseValues |
boolean |
<optional> |
true | Convert string "value" to "'value'" or not. (Convert by default) |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
le(field, value, normaliseValueopt) → {ODataFilterBuilder}
Less than or Equal
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare | ||
value |
string | number | * | A value to compare with | ||
normaliseValue |
boolean |
<optional> |
true | Convert string "value" to "'value'" or not. (Convert by default) |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
lt(field, value, normaliseValueopt) → {ODataFilterBuilder}
Less Than
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare | ||
value |
string | number | * | A value to compare with | ||
normaliseValue |
boolean |
<optional> |
true | Convert string "value" to "'value'" or not. (Convert by default) |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
ne(field, value, normaliseValueopt) → {ODataFilterBuilder}
Not Equal
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare | ||
value |
string | number | * | A value to compare with | ||
normaliseValue |
boolean |
<optional> |
true | Convert string "value" to "'value'" or not. (Convert by default) |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
not(rule) → {ODataFilterBuilder}
Logical Negation
Parameters:
Name | Type | Description |
---|---|---|
rule |
ODataFilterBuilder~InputRule | Rule to add |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
notIn(field, values, normaliseValuesopt) → {ODataFilterBuilder}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare | ||
values |
Array | Values to compare with | ||
normaliseValues |
boolean |
<optional> |
true | Convert string "value" to "'value'" or not. (Convert by default) |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
or(rule) → {ODataFilterBuilder}
Logical Or
Parameters:
Name | Type | Description |
---|---|---|
rule |
ODataFilterBuilder~InputRule | Rule to add |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
startsWith(field, value) → {ODataFilterBuilder}
The startswith function returns true if the first parameter string value starts with the second parameter string value.
Parameters:
Name | Type | Description |
---|---|---|
field |
ODataFilterBuilder~InputField | Field to compare |
value |
string | Value to compare |
- Source:
Returns:
The ODataFilterBuilder instance
- Type
- ODataFilterBuilder
Example
// return startswith(CompanyName,'Alfr')
toString() → {string}
Convert filter builder instance to string
This:
- Source:
Returns:
A source string representation
- Type
- string
Type Definitions
fieldLambdaExpression() → {string}
The comparison field lambda expression
Parameters:
Type | Description |
---|---|
ODataFilterBuilder.functions | Filter canonical functions (toLower, substring, ...) |
- Source:
Returns:
- Type
- string
Example
f()
.eq(x => x.toLower('Name'), 'a')
.toString();
// tolower(Name) eq 'a'
InputField
The comparison input field
Type:
- Source:
Example
f().contains(inputField, 'a')
// string
f().contains('tolower(Name)', 'a');
// fieldLambdaExpression
f().contains(x => x.toLower('Name', ''), 'a');
// returns 'contains(tolower(Name), 'a')
InputRule
The comparison input rule
Type:
- Source:
Example
f().and(inputRule)
// string
f().and('Id eq 1');
// ODataFilterBuilder
f().and(f().eq('Id', 1));
// ruleLambdaExpression
f().and(x => x.eq('Id', 1));
ruleLambdaExpression() → {ODataFilterBuilder}
The comparison rule lambda expression
Parameters:
Type | Description |
---|---|
ODataFilterBuilder | A new instance of ODataFilterBuilder |
- Source:
Returns:
- Type
- ODataFilterBuilder
Example
f()
.and(x => x.eq('Type/Id', 1))
.and(x => x.contains('Name', 'a'))
.toString();
// (Type/Id eq 1) and (contains(Name, 'a'))
Source
The ODataFilterBuilder source rule object.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
condition |
string | A base condition ('and' OR 'or'). |
rules |
Array.<(ODataFilterBuilder~Source|string)> | Child rules related to base condition |
- Source: