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
- and
- count
- first
- max
- min
- or
- page
- returnAll
- returnCount
- returnFirst
- returnMax
- returnMin
- returnPage
- 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.
▸ 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
<TEntity
>
Returns only the first Entity that matches this query.
Promise
<TEntity
>
▸ max(field
): Promise
<TEntity
>
Finds the Entity with the maximal value for a field.
Name | Type | Description |
---|---|---|
field |
string |
The field with the maximal value. |
Promise
<TEntity
>
The Entity with the maximal value
▸ min(field
): Promise
<TEntity
>
Finds the Entity with the minimal value for a field.
Name | Type | Description |
---|---|---|
field |
string |
The field with the minimal value. |
Promise
<TEntity
>
The Entity 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 |
- |
Promise
<TEntity
[]>
An array of Entities matching the query.
▸ returnAll(options?
): Promise
<TEntity
[]>
Alias for Search.all.
Name | Type | Default value |
---|---|---|
options |
Object |
undefined |
options.pageSize |
number |
10 |
Promise
<TEntity
[]>
▸ returnCount(): Promise
<number
>
Alias for Search.count.
Promise
<number
>
▸ returnFirst(): Promise
<TEntity
>
Alias for Search.first.
Promise
<TEntity
>
▸ returnMax(field
): Promise
<TEntity
>
Alias for Search.max.
Name | Type |
---|---|
field |
string |
Promise
<TEntity
>
▸ returnMin(field
): Promise
<TEntity
>
Alias for Search.min.
Name | Type |
---|---|
field |
string |
Promise
<TEntity
>
▸ returnPage(offset
, count
): Promise
<TEntity
[]>
Alias for Search.page.
Name | Type |
---|---|
offset |
number |
count |
number |
Promise
<TEntity
[]>
▸ 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
.