Class: WhereField
July 15, 2024 · View on GitHub
redis-om / WhereField
Class: WhereField<T>
Abstract base class that all fields you want to filter with extend. When you call where, a subclass of this is returned.
Type parameters
| Name | Type |
|---|---|
T | extends Entity = Record<string, any> |
Hierarchy
-
↳
WhereField
Table of contents
Properties
Accessors
Methods
- after
- before
- between
- contain
- containOneOf
- contains
- containsOneOf
- eq
- equal
- equalTo
- equals
- false
- greaterThan
- greaterThanOrEqualTo
- gt
- gte
- inCircle
- inRadius
- lessThan
- lessThanOrEqualTo
- lt
- lte
- match
- matchExact
- matchExactly
- matches
- matchesExactly
- on
- onOrAfter
- onOrBefore
- toString
- true
Properties
exact
• Readonly exact: WhereField<T>
Makes a call to match a matchExact call. Calling this multiple times will have no effect.
Defined in
exactly
• Readonly exactly: WhereField<T>
Makes a call to match a matchExact call. Calling this multiple times will have no effect.
Defined in
Accessors
does
• get does(): this
Returns the current instance. Syntactic sugar to make your code more fluent.
Returns
this
this
Defined in
is
• get is(): this
Returns the current instance. Syntactic sugar to make your code more fluent.
Returns
this
this
Defined in
not
• get not(): this
Negates the query on the field, cause it to match when the condition is not met. Calling this multiple times will negate the negation.
Returns
this
this
Defined in
Methods
after
▸ after(value): Search<T>
Add a search that matches all datetimes after the provided UTC datetime to the query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The datetime to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
before
▸ before(value): Search<T>
Add a search that matches all datetimes before the provided UTC datetime to the query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The datetime to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
between
▸ between(lower, upper): Search<T>
Adds an inclusive range comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
lower | string | number | Date | The lower bound of the range. |
upper | string | number | Date | The upper bound of the range. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
contain
▸ contain(value): Search<T>
Adds a whole-string match for a value within a string array to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | The string to be matched. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
containOneOf
▸ containOneOf(...value): Search<T>
Adds a whole-string match against a string array to the query. If any of the provided
strings in value is matched in the array, this matched.
Parameters
| Name | Type | Description |
|---|---|---|
...value | string[] | An array of strings that you want to match one of. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
contains
▸ contains(value): Search<T>
Adds a whole-string match for a value within a string array to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | The string to be matched. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
containsOneOf
▸ containsOneOf(...value): Search<T>
Adds a whole-string match against a string array to the query. If any of the provided
strings in value is matched in the array, this matched.
Parameters
| Name | Type | Description |
|---|---|---|
...value | string[] | An array of strings that you want to match one of. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
eq
▸ eq(value): Search<T>
Adds an equals comparison to the query.
NOTE: this function is not available for strings where full-text
search is enabled. In that scenario, use .match.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | Date | The value to be compared |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
equal
▸ equal(value): Search<T>
Adds an equals comparison to the query.
NOTE: this function is not available for strings where full-text
search is enabled. In that scenario, use .match.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | Date | The value to be compared |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
equalTo
▸ equalTo(value): Search<T>
Adds an equals comparison to the query.
NOTE: this function is not available for strings where full-text
search is enabled. In that scenario, use .match.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | Date | The value to be compared |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
equals
▸ equals(value): Search<T>
Adds an equals comparison to the query.
NOTE: this function is not available for strings where full-text
search is enabled. In that scenario, use .match.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | Date | The value to be compared |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
false
▸ false(): Search<T>
Adds a boolean match with a value of false to the query.
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
greaterThan
▸ greaterThan(value): Search<T>
Adds a greater than comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The value to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
greaterThanOrEqualTo
▸ greaterThanOrEqualTo(value): Search<T>
Adds a greater than or equal to comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The value to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
gt
▸ gt(value): Search<T>
Adds a greater than comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The value to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
gte
▸ gte(value): Search<T>
Adds a greater than or equal to comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The value to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
inCircle
▸ inCircle(circleFn): Search<T>
Adds a search for points that fall within a defined circle.
Parameters
| Name | Type | Description |
|---|---|---|
circleFn | CircleFunction | A function that returns a Circle instance defining the search area. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
inRadius
▸ inRadius(circleFn): Search<T>
Adds a search for points that fall within a defined radius.
Parameters
| Name | Type | Description |
|---|---|---|
circleFn | CircleFunction | A function that returns a Circle instance defining the search area. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
lessThan
▸ lessThan(value): Search<T>
Adds a less than comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The value to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
lessThanOrEqualTo
▸ lessThanOrEqualTo(value): Search<T>
Adds a less than or equal to comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The value to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
lt
▸ lt(value): Search<T>
Adds a less than comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The value to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
lte
▸ lte(value): Search<T>
Adds a less than or equal to comparison against a field to the search query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The value to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
match
▸ match(value, options?): Search<T>
Adds a full-text search comparison to the query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | The word or phrase sought. |
options? | Object | |
options.fuzzyMatching? | boolean | Whether to use fuzzy matching to find the sought word or phrase. Defaults to false. |
options.levenshteinDistance? | 2 | 1 | 3 | The levenshtein distance to use for fuzzy matching. Supported values are 1, 2, and 3. Defaults to 1. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
matchExact
▸ matchExact(value): Search<T>
Adds a full-text search comparison to the query that matches an exact word or phrase.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | The word or phrase sought. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
matchExactly
▸ matchExactly(value): Search<T>
Adds a full-text search comparison to the query that matches an exact word or phrase.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | The word or phrase sought. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
matches
▸ matches(value, options?): Search<T>
Adds a full-text search comparison to the query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | The word or phrase sought. |
options? | Object | |
options.fuzzyMatching? | boolean | Whether to use fuzzy matching to find the sought word or phrase. Defaults to false. |
options.levenshteinDistance? | 2 | 1 | 3 | The levenshtein distance to use for fuzzy matching. Supported values are 1, 2, and 3. Defaults to 1. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
matchesExactly
▸ matchesExactly(value): Search<T>
Adds a full-text search comparison to the query that matches an exact word or phrase.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | boolean | The word or phrase sought. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
on
▸ on(value): Search<T>
Add a search for an exact UTC datetime to the query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The datetime to match. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
onOrAfter
▸ onOrAfter(value): Search<T>
Add a search that matches all datetimes on or after the provided UTC datetime to the query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The datetime to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
onOrBefore
▸ onOrBefore(value): Search<T>
Add a search that matches all datetimes on or before the provided UTC datetime to the query.
Parameters
| Name | Type | Description |
|---|---|---|
value | string | number | Date | The datetime to compare against. |
Returns
Search<T>
The Search that was called to create this WhereField.
Defined in
toString
▸ Abstract toString(): string
Converts this Where into a portion of a RediSearch query.
Returns
string
Inherited from
Defined in
true
▸ true(): Search<T>
Adds a boolean match with a value of true to the query.
Returns
Search<T>
The Search that was called to create this WhereField.