Skip to content

Latest commit

 

History

History
229 lines (131 loc) · 5.48 KB

Search.md

File metadata and controls

229 lines (131 loc) · 5.48 KB

redis-om / Search

Class: Search<TEntity>

Entry point to fluent search. Requires the RediSearch or RedisJSON is installed.

Type parameters

Name Type Description
TEntity extends Entity The type of Entity being sought.

Table of contents

Methods

Methods

and

and(field): WhereField<TEntity>

Sets up a query matching a particular field as a logical AND.

Parameters

Name Type Description
field string The field to filter on.

Returns

WhereField<TEntity>

A subclass of WhereField matching the type of the field.

Defined in

lib/search/search.ts:125

and(subSearchFn): Search<TEntity>

Sets up a nested search as a logical AND.

Parameters

Name Type Description
subSearchFn SubSearchFunction<TEntity> A function that takes a Search and returns another Search.

Returns

Search<TEntity>

this.

Defined in

lib/search/search.ts:132


count

count(): Promise<number>

Returns the number of Entities that match this query.

Returns

Promise<number>

Defined in

lib/search/search.ts:52


or

or(field): WhereField<TEntity>

Sets up a query matching a particular field as a logical OR.

Parameters

Name Type Description
field string The field to filter on.

Returns

WhereField<TEntity>

A subclass of WhereField matching the type of the field.

Defined in

lib/search/search.ts:142

or(subSearchFn): Search<TEntity>

Sets up a nested search as a logical OR.

Parameters

Name Type Description
subSearchFn SubSearchFunction<TEntity> A function that takes a Search and returns another Search.

Returns

Search<TEntity>

this.

Defined in

lib/search/search.ts:149


return

return(offset, count): Promise<TEntity[]>

Returns a page of Entities that match this query.

Parameters

Name Type Description
offset number The offset for where to start returning Entities.
count number -

Returns

Promise<TEntity[]>

An array of Entities matching the query.

Defined in

lib/search/search.ts:65


returnAll

returnAll(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 });

Parameters

Name Type Default value Description
options Object undefined Options for the call.
options.pageSize number 10 Number of Entities returned per batch.

Returns

Promise<TEntity[]>

An array of Entities matching the query.

Defined in

lib/search/search.ts:86


where

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.

Parameters

Name Type Description
field string The field to filter on.

Returns

WhereField<TEntity>

A subclass of WhereField matching the type of the field.

Defined in

lib/search/search.ts:107

where(subSearchFn): Search<TEntity>

Sets up a nested search. If there are multiple calls to Search.where, they are treated logically as AND.

Parameters

Name Type Description
subSearchFn SubSearchFunction<TEntity> A function that takes a Search and returns another Search.

Returns

Search<TEntity>

this.

Defined in

lib/search/search.ts:115