Skip to content

Latest commit

 

History

History
158 lines (90 loc) · 2.93 KB

Client.md

File metadata and controls

158 lines (90 loc) · 2.93 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.

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

Methods

close

close(): Promise<void>

Close the connection to Redis.

Returns

Promise<void>


fetchRepository

fetchRepository(schema): Repository

Creates a repository for the given schema.

Parameters

Name Type Description
schema Schema The schema.

Returns

Repository

A repository for the provided schema.


isOpen

isOpen(): boolean

Returns

boolean

Whether a connection is already open.


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.


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.


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.