Skip to content

Latest commit

 

History

History
1201 lines (672 loc) · 25.6 KB

Search.md

File metadata and controls

1201 lines (672 loc) · 25.6 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:333

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:

const 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:266


allIds

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

Parameters

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

Returns

Promise<string[]>

An array of entity IDs matching the query.

Inherited from

AbstractSearch.allIds

Defined in

lib/search/search.ts:295


allKeys

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

Parameters

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

Returns

Promise<string[]>

An array of key names matching the query.

Inherited from

AbstractSearch.allKeys

Defined in

lib/search/search.ts:314


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

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


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


first

first(): Promise<null | TEntity>

Returns the first Entity that matches this query.

Returns

Promise<null | TEntity>

Inherited from

AbstractSearch.first

Defined in

lib/search/search.ts:231


firstId

firstId(): Promise<null | string>

Returns the first entity ID that matches this query.

Returns

Promise<null | string>

Inherited from

AbstractSearch.firstId

Defined in

lib/search/search.ts:239


firstKey

firstKey(): Promise<null | string>

Returns the first key name that matches this query.

Returns

Promise<null | string>

Inherited from

AbstractSearch.firstKey

Defined in

lib/search/search.ts:247


max

max(field): Promise<null | 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<null | TEntity>

The entity ID Entity with the maximal value

Inherited from

AbstractSearch.max

Defined in

lib/search/search.ts:159


maxId

maxId(field): Promise<null | string>

Finds the entity ID with the maximal value for a field.

Parameters

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

Returns

Promise<null | string>

The entity ID with the maximal value

Inherited from

AbstractSearch.maxId

Defined in

lib/search/search.ts:168


maxKey

maxKey(field): Promise<null | string>

Finds the key name in Redis with the maximal value for a field.

Parameters

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

Returns

Promise<null | string>

The key name with the maximal value

Inherited from

AbstractSearch.maxKey

Defined in

lib/search/search.ts:178


min

min(field): Promise<null | 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<null | TEntity>

The Entity with the minimal value

Inherited from

AbstractSearch.min

Defined in

lib/search/search.ts:131


minId

minId(field): Promise<null | string>

Finds the entity ID with the minimal value for a field.

Parameters

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

Returns

Promise<null | string>

The entity ID with the minimal value

Inherited from

AbstractSearch.minId

Defined in

lib/search/search.ts:140


minKey

minKey(field): Promise<null | string>

Finds the key name in Redis with the minimal value for a field.

Parameters

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

Returns

Promise<null | string>

The key name with the minimal value

Inherited from

AbstractSearch.minKey

Defined in

lib/search/search.ts:150


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

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


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 The number of Entities to return.

Returns

Promise<TEntity[]>

An array of Entities matching the query.

Inherited from

AbstractSearch.page

Defined in

lib/search/search.ts:199


pageOfIds

pageOfIds(offset, count): Promise<string[]>

Returns a page of entity IDs that match this query.

Parameters

Name Type Description
offset number The offset for where to start returning entity IDs.
count number The number of entity IDs to return.

Returns

Promise<string[]>

An array of strings matching the query.

Inherited from

AbstractSearch.pageOfIds

Defined in

lib/search/search.ts:212


pageOfKeys

pageOfKeys(offset, count): Promise<string[]>

Returns a page of key names in Redis that match this query.

Parameters

Name Type Description
offset number The offset for where to start returning key names.
count number The number of key names to return.

Returns

Promise<string[]>

An array of strings matching the query.

Inherited from

AbstractSearch.pageOfKeys

Defined in

lib/search/search.ts:223


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


returnAllIds

returnAllIds(options?): Promise<string[]>

Alias for Search.allIds.

Parameters

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

Returns

Promise<string[]>

Inherited from

AbstractSearch.returnAllIds

Defined in

lib/search/search.ts:438


returnAllKeys

returnAllKeys(options?): Promise<string[]>

Alias for Search.allKeys.

Parameters

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

Returns

Promise<string[]>

Inherited from

AbstractSearch.returnAllKeys

Defined in

lib/search/search.ts:445


returnCount

returnCount(): Promise<number>

Alias for Search.count.

Returns

Promise<number>

Inherited from

AbstractSearch.returnCount

Defined in

lib/search/search.ts:382


returnFirst

returnFirst(): Promise<null | TEntity>

Alias for Search.first.

Returns

Promise<null | TEntity>

Inherited from

AbstractSearch.returnFirst

Defined in

lib/search/search.ts:410


returnFirstId

returnFirstId(): Promise<null | string>

Alias for Search.firstId.

Returns

Promise<null | string>

Inherited from

AbstractSearch.returnFirstId

Defined in

lib/search/search.ts:417


returnFirstKey

returnFirstKey(): Promise<null | string>

Alias for Search.firstKey.

Returns

Promise<null | string>

Inherited from

AbstractSearch.returnFirstKey

Defined in

lib/search/search.ts:424


returnMax

returnMax(field): Promise<null | TEntity>

Alias for Search.max.

Parameters

Name Type
field string

Returns

Promise<null | TEntity>

Inherited from

AbstractSearch.returnMax

Defined in

lib/search/search.ts:361


returnMaxId

returnMaxId(field): Promise<null | string>

Alias for Search.maxId.

Parameters

Name Type
field string

Returns

Promise<null | string>

Inherited from

AbstractSearch.returnMaxId

Defined in

lib/search/search.ts:368


returnMaxKey

returnMaxKey(field): Promise<null | string>

Alias for Search.maxKey.

Parameters

Name Type
field string

Returns

Promise<null | string>

Inherited from

AbstractSearch.returnMaxKey

Defined in

lib/search/search.ts:375


returnMin

returnMin(field): Promise<null | TEntity>

Alias for Search.min.

Parameters

Name Type
field string

Returns

Promise<null | TEntity>

Inherited from

AbstractSearch.returnMin

Defined in

lib/search/search.ts:340


returnMinId

returnMinId(field): Promise<null | string>

Alias for Search.minId.

Parameters

Name Type
field string

Returns

Promise<null | string>

Inherited from

AbstractSearch.returnMinId

Defined in

lib/search/search.ts:347


returnMinKey

returnMinKey(field): Promise<null | string>

Alias for Search.minKey.

Parameters

Name Type
field string

Returns

Promise<null | string>

Inherited from

AbstractSearch.returnMinKey

Defined in

lib/search/search.ts:354


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


returnPageOfIds

returnPageOfIds(offset, count): Promise<string[]>

Alias for Search.pageOfIds.

Parameters

Name Type
offset number
count number

Returns

Promise<string[]>

Inherited from

AbstractSearch.returnPageOfIds

Defined in

lib/search/search.ts:396


returnPageOfKeys

returnPageOfKeys(offset, count): Promise<string[]>

Alias for {@link Search.pageOrKeys}.

Parameters

Name Type
offset number
count number

Returns

Promise<string[]>

Inherited from

AbstractSearch.returnPageOfKeys

Defined in

lib/search/search.ts:403


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


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


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


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


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


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

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