Skip to content

Latest commit

 

History

History
758 lines (441 loc) · 14.5 KB

AbstractSearch.md

File metadata and controls

758 lines (441 loc) · 14.5 KB

redis-om / AbstractSearch

Class: AbstractSearch

Abstract base class for Search and RawSearch that contains methods to return search results.

template The type of Entity being sought.

Hierarchy

Table of contents

Accessors

Methods

Accessors

return

get return(): AbstractSearch

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

Returns

AbstractSearch

this

Methods

all

all(options?): Promise<Entity[]>

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<Entity[]>

An array of Entities matching the query.


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.


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.


count

count(): Promise<number>

Returns the number of Entities that match this query.

Returns

Promise<number>


first

first(): Promise<null | Entity>

Returns the first Entity that matches this query.

Returns

Promise<null | Entity>


firstId

firstId(): Promise<null | string>

Returns the first entity ID that matches this query.

Returns

Promise<null | string>


firstKey

firstKey(): Promise<null | string>

Returns the first key name that matches this query.

Returns

Promise<null | string>


max

max(field): Promise<null | Entity>

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 | Entity>

The entity ID Entity with the maximal value


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


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


min

min(field): Promise<null | Entity>

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 | Entity>

The Entity with the minimal value


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


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


page

page(offset, count): Promise<Entity[]>

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<Entity[]>

An array of Entities matching the query.


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.


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.


returnAll

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

Alias for all.

Parameters

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

Returns

Promise<Entity[]>


returnAllIds

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

Alias for allIds.

Parameters

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

Returns

Promise<string[]>


returnAllKeys

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

Alias for allKeys.

Parameters

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

Returns

Promise<string[]>


returnCount

returnCount(): Promise<number>

Alias for count.

Returns

Promise<number>


returnFirst

returnFirst(): Promise<null | Entity>

Alias for first.

Returns

Promise<null | Entity>


returnFirstId

returnFirstId(): Promise<null | string>

Alias for firstId.

Returns

Promise<null | string>


returnFirstKey

returnFirstKey(): Promise<null | string>

Alias for firstKey.

Returns

Promise<null | string>


returnMax

returnMax(field): Promise<null | Entity>

Alias for max.

Parameters

Name Type
field string

Returns

Promise<null | Entity>


returnMaxId

returnMaxId(field): Promise<null | string>

Alias for maxId.

Parameters

Name Type
field string

Returns

Promise<null | string>


returnMaxKey

returnMaxKey(field): Promise<null | string>

Alias for maxKey.

Parameters

Name Type
field string

Returns

Promise<null | string>


returnMin

returnMin(field): Promise<null | Entity>

Alias for min.

Parameters

Name Type
field string

Returns

Promise<null | Entity>


returnMinId

returnMinId(field): Promise<null | string>

Alias for minId.

Parameters

Name Type
field string

Returns

Promise<null | string>


returnMinKey

returnMinKey(field): Promise<null | string>

Alias for minKey.

Parameters

Name Type
field string

Returns

Promise<null | string>


returnPage

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

Alias for page.

Parameters

Name Type
offset number
count number

Returns

Promise<Entity[]>


returnPageOfIds

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

Alias for pageOfIds.

Parameters

Name Type
offset number
count number

Returns

Promise<string[]>


returnPageOfKeys

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

Alias for pageOfKeys.

Parameters

Name Type
offset number
count number

Returns

Promise<string[]>


sortAsc

sortAsc(field): AbstractSearch

Alias for sortAscending.

Parameters

Name Type
field string

Returns

AbstractSearch


sortAscending

sortAscending(field): AbstractSearch

Applies an ascending sort to the query.

Parameters

Name Type Description
field string The field to sort by.

Returns

AbstractSearch

this


sortBy

sortBy(fieldName, order?): AbstractSearch

Applies sorting for the query.

Parameters

Name Type Default value Description
fieldName string undefined -
order "ASC" | "DESC" 'ASC' The order of returned Entities Defaults to ASC (ascending) if not specified

Returns

AbstractSearch

this


sortDesc

sortDesc(field): AbstractSearch

Alias for sortDescending.

Parameters

Name Type
field string

Returns

AbstractSearch


sortDescending

sortDescending(field): AbstractSearch

Applies a descending sort to the query.

Parameters

Name Type Description
field string The field to sort by.

Returns

AbstractSearch

this