redis-om / Search
Entry point to fluent search. This is the default Redis OM experience. Requires that RediSearch (and optionally RedisJSON) be installed.
Name | Type | Description |
---|---|---|
TEntity |
extends Entity |
The type of Entity being sought. |
-
AbstractSearch
<TEntity
>↳
Search
- all
- allIds
- allKeys
- and
- count
- first
- firstId
- firstKey
- max
- maxId
- maxKey
- min
- minId
- minKey
- or
- page
- pageOfIds
- pageOfKeys
- returnAll
- returnAllIds
- returnAllKeys
- returnCount
- returnFirst
- returnFirstId
- returnFirstKey
- returnMax
- returnMaxId
- returnMaxKey
- returnMin
- returnMinId
- returnMinKey
- returnPage
- returnPageOfIds
- returnPageOfKeys
- sortAsc
- sortAscending
- sortBy
- sortDesc
- sortDescending
- where
• get
return(): AbstractSearch
<TEntity
>
Returns the current instance. Syntactic sugar to make your code more fluent.
AbstractSearch
<TEntity
>
this
AbstractSearch.return
▸ all(options?
): Promise
<TEntity
[]>
Returns all the Entities that match this query. This method
makes multiple calls to Redis until all the Entities are returned.
You can specify the batch size by setting the pageSize
property on the
options:
const entities = await repository.search().returnAll({ pageSize: 100 });
Name | Type | Default value | Description |
---|---|---|---|
options |
Object |
undefined |
Options for the call. |
options.pageSize |
number |
10 |
Number of Entities returned per batch. |
Promise
<TEntity
[]>
An array of Entities matching the query.
▸ allIds(options?
): Promise
<string
[]>
Returns all the entity IDs that match this query. This method
makes multiple calls to Redis until all the entity IDs are returned.
You can specify the batch size by setting the pageSize
property on the
options:
const keys = await repository.search().returnAllIds({ pageSize: 100 });
Name | Type | Default value | Description |
---|---|---|---|
options |
Object |
undefined |
Options for the call. |
options.pageSize |
number |
10 |
Number of entity IDs returned per batch. |
Promise
<string
[]>
An array of entity IDs matching the query.
▸ allKeys(options?
): Promise
<string
[]>
Returns all the key names in Redis that match this query. This method
makes multiple calls to Redis until all the key names are returned.
You can specify the batch size by setting the pageSize
property on the
options:
const keys = await repository.search().returnAllKeys({ pageSize: 100 });
Name | Type | Default value | Description |
---|---|---|---|
options |
Object |
undefined |
Options for the call. |
options.pageSize |
number |
10 |
Number of key names returned per batch. |
Promise
<string
[]>
An array of key names matching the query.
▸ and(field
): WhereField
<TEntity
>
Sets up a query matching a particular field as a logical AND.
Name | Type | Description |
---|---|---|
field |
string |
The field to filter on. |
WhereField
<TEntity
>
A subclass of WhereField matching the type of the field.
▸ and(subSearchFn
): Search
<TEntity
>
Sets up a nested search as a logical AND.
Name | Type | Description |
---|---|---|
subSearchFn |
SubSearchFunction <TEntity > |
A function that takes a Search and returns another Search. |
Search
<TEntity
>
this
.
▸ count(): Promise
<number
>
Returns the number of Entities that match this query.
Promise
<number
>
▸ first(): Promise
<null
| TEntity
>
Returns the first Entity that matches this query.
Promise
<null
| TEntity
>
▸ firstId(): Promise
<null
| string
>
Returns the first entity ID that matches this query.
Promise
<null
| string
>
▸ firstKey(): Promise
<null
| string
>
Returns the first key name that matches this query.
Promise
<null
| string
>
▸ max(field
): Promise
<null
| TEntity
>
Finds the Entity with the maximal value for a field.
Name | Type | Description |
---|---|---|
field |
string |
The field with the maximal value. |
Promise
<null
| TEntity
>
The entity ID Entity with the maximal value
▸ maxId(field
): Promise
<null
| string
>
Finds the entity ID with the maximal value for a field.
Name | Type | Description |
---|---|---|
field |
string |
The field with the maximal value. |
Promise
<null
| string
>
The entity ID with the maximal value
▸ maxKey(field
): Promise
<null
| string
>
Finds the key name in Redis with the maximal value for a field.
Name | Type | Description |
---|---|---|
field |
string |
The field with the maximal value. |
Promise
<null
| string
>
The key name with the maximal value
▸ min(field
): Promise
<null
| TEntity
>
Finds the Entity with the minimal value for a field.
Name | Type | Description |
---|---|---|
field |
string |
The field with the minimal value. |
Promise
<null
| TEntity
>
The Entity with the minimal value
▸ minId(field
): Promise
<null
| string
>
Finds the entity ID with the minimal value for a field.
Name | Type | Description |
---|---|---|
field |
string |
The field with the minimal value. |
Promise
<null
| string
>
The entity ID with the minimal value
▸ minKey(field
): Promise
<null
| string
>
Finds the key name in Redis with the minimal value for a field.
Name | Type | Description |
---|---|---|
field |
string |
The field with the minimal value. |
Promise
<null
| string
>
The key name with the minimal value
▸ or(field
): WhereField
<TEntity
>
Sets up a query matching a particular field as a logical OR.
Name | Type | Description |
---|---|---|
field |
string |
The field to filter on. |
WhereField
<TEntity
>
A subclass of WhereField matching the type of the field.
▸ or(subSearchFn
): Search
<TEntity
>
Sets up a nested search as a logical OR.
Name | Type | Description |
---|---|---|
subSearchFn |
SubSearchFunction <TEntity > |
A function that takes a Search and returns another Search. |
Search
<TEntity
>
this
.
▸ page(offset
, count
): Promise
<TEntity
[]>
Returns a page of Entities that match this query.
Name | Type | Description |
---|---|---|
offset |
number |
The offset for where to start returning Entities. |
count |
number |
The number of Entities to return. |
Promise
<TEntity
[]>
An array of Entities matching the query.
▸ pageOfIds(offset
, count
): Promise
<string
[]>
Returns a page of entity IDs that match this query.
Name | Type | Description |
---|---|---|
offset |
number |
The offset for where to start returning entity IDs. |
count |
number |
The number of entity IDs to return. |
Promise
<string
[]>
An array of strings matching the query.
▸ pageOfKeys(offset
, count
): Promise
<string
[]>
Returns a page of key names in Redis that match this query.
Name | Type | Description |
---|---|---|
offset |
number |
The offset for where to start returning key names. |
count |
number |
The number of key names to return. |
Promise
<string
[]>
An array of strings matching the query.
▸ returnAll(options?
): Promise
<TEntity
[]>
Alias for Search.all.
Name | Type | Default value |
---|---|---|
options |
Object |
undefined |
options.pageSize |
number |
10 |
Promise
<TEntity
[]>
▸ returnAllIds(options?
): Promise
<string
[]>
Alias for Search.allIds.
Name | Type | Default value |
---|---|---|
options |
Object |
undefined |
options.pageSize |
number |
10 |
Promise
<string
[]>
▸ returnAllKeys(options?
): Promise
<string
[]>
Alias for Search.allKeys.
Name | Type | Default value |
---|---|---|
options |
Object |
undefined |
options.pageSize |
number |
10 |
Promise
<string
[]>
▸ returnCount(): Promise
<number
>
Alias for Search.count.
Promise
<number
>
▸ returnFirst(): Promise
<null
| TEntity
>
Alias for Search.first.
Promise
<null
| TEntity
>
▸ returnFirstId(): Promise
<null
| string
>
Alias for Search.firstId.
Promise
<null
| string
>
▸ returnFirstKey(): Promise
<null
| string
>
Alias for Search.firstKey.
Promise
<null
| string
>
▸ returnMax(field
): Promise
<null
| TEntity
>
Alias for Search.max.
Name | Type |
---|---|
field |
string |
Promise
<null
| TEntity
>
▸ returnMaxId(field
): Promise
<null
| string
>
Alias for Search.maxId.
Name | Type |
---|---|
field |
string |
Promise
<null
| string
>
▸ returnMaxKey(field
): Promise
<null
| string
>
Alias for Search.maxKey.
Name | Type |
---|---|
field |
string |
Promise
<null
| string
>
▸ returnMin(field
): Promise
<null
| TEntity
>
Alias for Search.min.
Name | Type |
---|---|
field |
string |
Promise
<null
| TEntity
>
▸ returnMinId(field
): Promise
<null
| string
>
Alias for Search.minId.
Name | Type |
---|---|
field |
string |
Promise
<null
| string
>
▸ returnMinKey(field
): Promise
<null
| string
>
Alias for Search.minKey.
Name | Type |
---|---|
field |
string |
Promise
<null
| string
>
▸ returnPage(offset
, count
): Promise
<TEntity
[]>
Alias for Search.page.
Name | Type |
---|---|
offset |
number |
count |
number |
Promise
<TEntity
[]>
▸ returnPageOfIds(offset
, count
): Promise
<string
[]>
Alias for Search.pageOfIds.
Name | Type |
---|---|
offset |
number |
count |
number |
Promise
<string
[]>
AbstractSearch.returnPageOfIds
▸ returnPageOfKeys(offset
, count
): Promise
<string
[]>
Alias for {@link Search.pageOrKeys}.
Name | Type |
---|---|
offset |
number |
count |
number |
Promise
<string
[]>
AbstractSearch.returnPageOfKeys
▸ sortAsc(field
): AbstractSearch
<TEntity
>
Alias for Search.sortAscending.
Name | Type |
---|---|
field |
string |
AbstractSearch
<TEntity
>
▸ sortAscending(field
): AbstractSearch
<TEntity
>
Applies an ascending sort to the query.
Name | Type | Description |
---|---|---|
field |
string |
The field to sort by. |
AbstractSearch
<TEntity
>
this
▸ sortBy(field
, order?
): AbstractSearch
<TEntity
>
Applies sorting for the query.
Name | Type | Default value | Description |
---|---|---|---|
field |
string |
undefined |
The field to sort by. |
order |
"ASC" | "DESC" |
'ASC' |
The order of returned Entities Defaults to ASC (ascending) if not specified |
AbstractSearch
<TEntity
>
this
▸ sortDesc(field
): AbstractSearch
<TEntity
>
Alias for Search.sortDescending.
Name | Type |
---|---|
field |
string |
AbstractSearch
<TEntity
>
▸ sortDescending(field
): AbstractSearch
<TEntity
>
Applies a descending sort to the query.
Name | Type | Description |
---|---|---|
field |
string |
The field to sort by. |
AbstractSearch
<TEntity
>
this
▸ where(field
): WhereField
<TEntity
>
Sets up a query matching a particular field. If there are multiple calls to Search.where, they are treated logically as AND.
Name | Type | Description |
---|---|---|
field |
string |
The field to filter on. |
WhereField
<TEntity
>
A subclass of WhereField matching the type of the field.
▸ where(subSearchFn
): Search
<TEntity
>
Sets up a nested search. If there are multiple calls to Search.where, they are treated logically as AND.
Name | Type | Description |
---|---|---|
subSearchFn |
SubSearchFunction <TEntity > |
A function that takes a Search and returns another Search. |
Search
<TEntity
>
this
.