redis-om / Search
Entry point to fluent search. Requires the RediSearch or RedisJSON is installed.
Name | Type | Description |
---|---|---|
TEntity |
extends Entity |
The type of Entity being sought. |
• get
return(): Search
<TEntity
>
Returns the current instance. Syntactic sugar to make your code more fluent.
Search
<TEntity
>
this
▸ 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:
let 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
>
▸ 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
>
▸ returnPage(offset
, count
): Promise
<TEntity
[]>
Alias for Search.page.
Name | Type |
---|---|
offset |
number |
count |
number |
Promise
<TEntity
[]>
▸ 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
.