Skip to content

Latest commit

 

History

History
196 lines (110 loc) · 4.05 KB

Client.md

File metadata and controls

196 lines (110 loc) · 4.05 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:

const client = new Client()
await client.open()

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

Deprecated

Just use Node Redis client directly and pass it to the Repository.

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new Client()

Accessors

redis

get redis(): undefined | RedisConnection

Returns the underlying Node Redis connection being used.

Returns

undefined | RedisConnection

Defined in

lib/client/client.ts:70

Methods

close

close(): Promise<void>

Close the connection to Redis.

Returns

Promise<void>

Defined in

lib/client/client.ts:127


fetchRepository

fetchRepository<T>(schema): Repository<InferSchema<T>>

Creates a repository for the given schema.

Type parameters

Name Type
T extends Schema<any, T>

Parameters

Name Type Description
schema T The schema.

Returns

Repository<InferSchema<T>>

A repository for the provided schema.

Defined in

lib/client/client.ts:119


isOpen

isOpen(): boolean

Returns

boolean

Whether a connection is already open.

Defined in

lib/client/client.ts:213


open

open(url?): Promise<Client>

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

This Client instance.

Defined in

lib/client/client.ts:104


use

use(connection): Promise<Client>

Attaches an existing Node Redis connection to this Redis OM client. Closes any existing connection.

Parameters

Name Type Description
connection RedisConnection An existing Node Redis client.

Returns

Promise<Client>

This Client instance.

Defined in

lib/client/client.ts:81


useNoClose

useNoClose(connection): Client

Attaches an existing Node Redis connection to this Redis OM client. Does not close any existing connection.

Parameters

Name Type Description
connection RedisConnection An existing Node Redis client.

Returns

Client

This Client instance.

Defined in

lib/client/client.ts:93