Skip to content

Latest commit

 

History

History
149 lines (85 loc) · 3 KB

Client.md

File metadata and controls

149 lines (85 loc) · 3 KB

redis-om / Client

Class: Client

A Client is the starting point for working with Redis OM. Clients manage the connection to Redis and provide limited functionality for executing Redis commands. Create a client and open it before you use it:

let client = new Client();
await client.open();

A Client is primarily used by a Repository which requires a client in its constructor.

Table of contents

Constructors

Methods

Constructors

constructor

new Client()

Methods

close

close(): Promise<void>

Close the connection to Redis.

Returns

Promise<void>

Defined in

lib/client.ts:95


execute

execute<TResult>(command): Promise<TResult>

Execute an arbitrary Redis command.

Type parameters

Name Description
TResult Expect result type such as string, string[], or whatever complex type Redis returns.

Parameters

Name Type Description
command (string | number | boolean)[] The command to execute.

Returns

Promise<TResult>

The raw results of calling the Redis command.

Defined in

lib/client.ts:72


fetchRepository

fetchRepository<TEntity>(schema): Repository<TEntity>

Creates a repository for the given schema.

Type parameters

Name Type Description
TEntity extends Entity<TEntity> The entity type for this {@lin Schema} and Repository.

Parameters

Name Type Description
schema Schema<TEntity> The schema.

Returns

Repository<TEntity>

A repository for the provided schema.

Defined in

lib/client.ts:87


isOpen

isOpen(): boolean

Returns

boolean

Whether a connection is already open

Defined in

lib/client.ts:168


open

open(url?): Promise<void>

Open a connection to Redis at the provided URL.

Parameters

Name Type Default value Description
url string 'redis://localhost:6379' A URL to Redis as defined with the IANA.

Returns

Promise<void>

Defined in

lib/client.ts:60