Skip to content

Latest commit

 

History

History
647 lines (360 loc) · 13.7 KB

Search.md

File metadata and controls

647 lines (360 loc) · 13.7 KB

redis-om / Search

Class: Search<TEntity>

Entry point to fluent search. This is the default Redis OM experience. Requires that RediSearch (and optionally RedisJSON) be installed.

Type parameters

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

Hierarchy

Table of contents

Accessors

Methods

Accessors

return

get return(): AbstractSearch<TEntity>

Returns the current instance. Syntactic sugar to make your code more fluent.

Returns

AbstractSearch<TEntity>

this

Inherited from

AbstractSearch.return

Defined in

lib/search/search.ts:210

Methods

all

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

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.

Inherited from

AbstractSearch.all

Defined in

lib/search/search.ts:191


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:340

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:347


count

count(): Promise<number>

Returns the number of Entities that match this query.

Returns

Promise<number>

Inherited from

AbstractSearch.count

Defined in

lib/search/search.ts:149


first

first(): Promise<TEntity>

Returns only the first Entity that matches this query.

Returns

Promise<TEntity>

Inherited from

AbstractSearch.first

Defined in

lib/search/search.ts:172


max

max(field): Promise<TEntity>

Finds the Entity with the maximal value for a field.

Parameters

Name Type Description
field string The field with the maximal value.

Returns

Promise<TEntity>

The Entity with the maximal value

Inherited from

AbstractSearch.max

Defined in

lib/search/search.ts:141


min

min(field): Promise<TEntity>

Finds the Entity with the minimal value for a field.

Parameters

Name Type Description
field string The field with the minimal value.

Returns

Promise<TEntity>

The Entity with the minimal value

Inherited from

AbstractSearch.min

Defined in

lib/search/search.ts:132


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:357

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:364


page

page(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.

Inherited from

AbstractSearch.page

Defined in

lib/search/search.ts:162


returnAll

returnAll(options?): Promise<TEntity[]>

Alias for Search.all.

Parameters

Name Type Default value
options Object undefined
options.pageSize number 10

Returns

Promise<TEntity[]>

Inherited from

AbstractSearch.returnAll

Defined in

lib/search/search.ts:245


returnCount

returnCount(): Promise<number>

Alias for Search.count.

Returns

Promise<number>

Inherited from

AbstractSearch.returnCount

Defined in

lib/search/search.ts:231


returnFirst

returnFirst(): Promise<TEntity>

Alias for Search.first.

Returns

Promise<TEntity>

Inherited from

AbstractSearch.returnFirst

Defined in

lib/search/search.ts:252


returnMax

returnMax(field): Promise<TEntity>

Alias for Search.max.

Parameters

Name Type
field string

Returns

Promise<TEntity>

Inherited from

AbstractSearch.returnMax

Defined in

lib/search/search.ts:224


returnMin

returnMin(field): Promise<TEntity>

Alias for Search.min.

Parameters

Name Type
field string

Returns

Promise<TEntity>

Inherited from

AbstractSearch.returnMin

Defined in

lib/search/search.ts:217


returnPage

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

Alias for Search.page.

Parameters

Name Type
offset number
count number

Returns

Promise<TEntity[]>

Inherited from

AbstractSearch.returnPage

Defined in

lib/search/search.ts:238


sortAsc

sortAsc(field): AbstractSearch<TEntity>

Alias for Search.sortAscending.

Parameters

Name Type
field string

Returns

AbstractSearch<TEntity>

Inherited from

AbstractSearch.sortAsc

Defined in

lib/search/search.ts:84


sortAscending

sortAscending(field): AbstractSearch<TEntity>

Applies an ascending sort to the query.

Parameters

Name Type Description
field string The field to sort by.

Returns

AbstractSearch<TEntity>

this

Inherited from

AbstractSearch.sortAscending

Defined in

lib/search/search.ts:61


sortBy

sortBy(field, order?): AbstractSearch<TEntity>

Applies sorting for the query.

Parameters

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

Returns

AbstractSearch<TEntity>

this

Inherited from

AbstractSearch.sortBy

Defined in

lib/search/search.ts:94


sortDesc

sortDesc(field): AbstractSearch<TEntity>

Alias for Search.sortDescending.

Parameters

Name Type
field string

Returns

AbstractSearch<TEntity>

Inherited from

AbstractSearch.sortDesc

Defined in

lib/search/search.ts:68


sortDescending

sortDescending(field): AbstractSearch<TEntity>

Applies a descending sort to the query.

Parameters

Name Type Description
field string The field to sort by.

Returns

AbstractSearch<TEntity>

this

Inherited from

AbstractSearch.sortDescending

Defined in

lib/search/search.ts:77


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:322

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:330