Class: AbstractSearch

July 15, 2024 · View on GitHub

redis-om / AbstractSearch

Class: AbstractSearch<T>

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

Template

The type of Entity being sought.

Type parameters

NameType
Textends Entity = Record<string, any>

Hierarchy

Table of contents

Accessors

Methods

Accessors

return

get return(): AbstractSearch<T>

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

Returns

AbstractSearch<T>

this

Defined in

lib/search/search.ts:329

Methods

all

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

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

NameTypeDefault valueDescription
optionsObjectundefinedOptions for the call.
options.pageSizenumber10Number of Entities returned per batch.

Returns

Promise<T[]>

An array of Entities matching the query.

Defined in

lib/search/search.ts:285


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

NameTypeDefault valueDescription
optionsObjectundefinedOptions for the call.
options.pageSizenumber10Number of entity IDs returned per batch.

Returns

Promise<string[]>

An array of entity IDs matching the query.

Defined in

lib/search/search.ts:303


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

NameTypeDefault valueDescription
optionsObjectundefinedOptions for the call.
options.pageSizenumber10Number of key names returned per batch.

Returns

Promise<string[]>

An array of key names matching the query.

Defined in

lib/search/search.ts:321


count

count(): Promise<number>

Returns the number of Entities that match this query.

Returns

Promise<number>

Defined in

lib/search/search.ts:209


first

first(): Promise<null | T>

Returns the first Entity that matches this query.

Returns

Promise<null | T>

Defined in

lib/search/search.ts:250


firstId

firstId(): Promise<null | string>

Returns the first entity ID that matches this query.

Returns

Promise<null | string>

Defined in

lib/search/search.ts:258


firstKey

firstKey(): Promise<null | string>

Returns the first key name that matches this query.

Returns

Promise<null | string>

Defined in

lib/search/search.ts:266


max

max(field): Promise<null | T>

Finds the Entity with the maximal value for a field.

Parameters

NameTypeDescription
fieldExclude<keyof T, keyof EntityInternal>The field with the maximal value.

Returns

Promise<null | T>

The entity ID Entity with the maximal value

Defined in

lib/search/search.ts:183


maxId

maxId(field): Promise<null | string>

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

Parameters

NameTypeDescription
fieldExclude<keyof T, keyof EntityInternal>The field with the maximal value.

Returns

Promise<null | string>

The entity ID with the maximal value

Defined in

lib/search/search.ts:192


maxKey

maxKey(field): Promise<null | string>

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

Parameters

NameTypeDescription
fieldExclude<keyof T, keyof EntityInternal>The field with the maximal value.

Returns

Promise<null | string>

The key name with the maximal value

Defined in

lib/search/search.ts:201


min

min(field): Promise<null | T>

Finds the Entity with the minimal value for a field.

Parameters

NameTypeDescription
fieldExclude<keyof T, keyof EntityInternal>The field with the minimal value.

Returns

Promise<null | T>

The Entity with the minimal value

Defined in

lib/search/search.ts:156


minId

minId(field): Promise<null | string>

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

Parameters

NameTypeDescription
fieldExclude<keyof T, keyof EntityInternal>The field with the minimal value.

Returns

Promise<null | string>

The entity ID with the minimal value

Defined in

lib/search/search.ts:165


minKey

minKey(field): Promise<null | string>

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

Parameters

NameTypeDescription
fieldExclude<keyof T, keyof EntityInternal>The field with the minimal value.

Returns

Promise<null | string>

The key name with the minimal value

Defined in

lib/search/search.ts:174


page

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

Returns a page of Entities that match this query.

Parameters

NameTypeDescription
offsetnumberThe offset for where to start returning Entities.
countnumberThe number of Entities to return.

Returns

Promise<T[]>

An array of Entities matching the query.

Defined in

lib/search/search.ts:220


pageOfIds

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

Returns a page of entity IDs that match this query.

Parameters

NameTypeDescription
offsetnumberThe offset for where to start returning entity IDs.
countnumberThe number of entity IDs to return.

Returns

Promise<string[]>

An array of strings matching the query.

Defined in

lib/search/search.ts:231


pageOfKeys

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

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

Parameters

NameTypeDescription
offsetnumberThe offset for where to start returning key names.
countnumberThe number of key names to return.

Returns

Promise<string[]>

An array of strings matching the query.

Defined in

lib/search/search.ts:242


returnAll

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

Alias for all.

Parameters

NameTypeDefault value
optionsObjectundefined
options.pageSizenumber10

Returns

Promise<T[]>

Defined in

lib/search/search.ts:427


returnAllIds

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

Alias for allIds.

Parameters

NameTypeDefault value
optionsObjectundefined
options.pageSizenumber10

Returns

Promise<string[]>

Defined in

lib/search/search.ts:434


returnAllKeys

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

Alias for allKeys.

Parameters

NameTypeDefault value
optionsObjectundefined
options.pageSizenumber10

Returns

Promise<string[]>

Defined in

lib/search/search.ts:441


returnCount

returnCount(): Promise<number>

Alias for count.

Returns

Promise<number>

Defined in

lib/search/search.ts:378


returnFirst

returnFirst(): Promise<null | T>

Alias for first.

Returns

Promise<null | T>

Defined in

lib/search/search.ts:406


returnFirstId

returnFirstId(): Promise<null | string>

Alias for firstId.

Returns

Promise<null | string>

Defined in

lib/search/search.ts:413


returnFirstKey

returnFirstKey(): Promise<null | string>

Alias for firstKey.

Returns

Promise<null | string>

Defined in

lib/search/search.ts:420


returnMax

returnMax(field): Promise<null | T>

Alias for max.

Parameters

NameType
fieldExclude<keyof T, keyof EntityInternal>

Returns

Promise<null | T>

Defined in

lib/search/search.ts:357


returnMaxId

returnMaxId(field): Promise<null | string>

Alias for maxId.

Parameters

NameType
fieldExclude<keyof T, keyof EntityInternal>

Returns

Promise<null | string>

Defined in

lib/search/search.ts:364


returnMaxKey

returnMaxKey(field): Promise<null | string>

Alias for maxKey.

Parameters

NameType
fieldExclude<keyof T, keyof EntityInternal>

Returns

Promise<null | string>

Defined in

lib/search/search.ts:371


returnMin

returnMin(field): Promise<null | T>

Alias for min.

Parameters

NameType
fieldExclude<keyof T, keyof EntityInternal>

Returns

Promise<null | T>

Defined in

lib/search/search.ts:336


returnMinId

returnMinId(field): Promise<null | string>

Alias for minId.

Parameters

NameType
fieldExclude<keyof T, keyof EntityInternal>

Returns

Promise<null | string>

Defined in

lib/search/search.ts:343


returnMinKey

returnMinKey(field): Promise<null | string>

Alias for minKey.

Parameters

NameType
fieldExclude<keyof T, keyof EntityInternal>

Returns

Promise<null | string>

Defined in

lib/search/search.ts:350


returnPage

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

Alias for page.

Parameters

NameType
offsetnumber
countnumber

Returns

Promise<T[]>

Defined in

lib/search/search.ts:385


returnPageOfIds

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

Alias for pageOfIds.

Parameters

NameType
offsetnumber
countnumber

Returns

Promise<string[]>

Defined in

lib/search/search.ts:392


returnPageOfKeys

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

Alias for pageOfKeys.

Parameters

NameType
offsetnumber
countnumber

Returns

Promise<string[]>

Defined in

lib/search/search.ts:399


sortAsc

sortAsc(field): AbstractSearch<T>

Alias for sortAscending.

Parameters

NameType
fieldExclude<keyof T, keyof EntityInternal>

Returns

AbstractSearch<T>

Defined in

lib/search/search.ts:92


sortAscending

sortAscending(field): AbstractSearch<T>

Applies an ascending sort to the query.

Parameters

NameTypeDescription
fieldExclude<keyof T, keyof EntityInternal>The field to sort by.

Returns

AbstractSearch<T>

this

Defined in

lib/search/search.ts:69


sortBy

sortBy(fieldName, order?): AbstractSearch<T>

Applies sorting for the query.

Parameters

NameTypeDefault valueDescription
fieldNameExclude<keyof T, keyof EntityInternal>undefinedThe field to sort by.
order"ASC" | "DESC""ASC"The order of returned Entities Defaults to ASC (ascending) if not specified

Returns

AbstractSearch<T>

this

Defined in

lib/search/search.ts:102


sortDesc

sortDesc(field): AbstractSearch<T>

Alias for sortDescending.

Parameters

NameType
fieldExclude<keyof T, keyof EntityInternal>

Returns

AbstractSearch<T>

Defined in

lib/search/search.ts:76


sortDescending

sortDescending(field): AbstractSearch<T>

Applies a descending sort to the query.

Parameters

NameTypeDescription
fieldExclude<keyof T, keyof EntityInternal>The field to sort by.

Returns

AbstractSearch<T>

this

Defined in

lib/search/search.ts:85