redis-om / 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.
• new Client()
▸ close(): Promise
<void
>
Close the connection to Redis.
Promise
<void
>
▸ execute<TResult
>(command
): Promise
<TResult
>
Execute an arbitrary Redis command.
Name | Description |
---|---|
TResult |
Expect result type such as string , string[] , or whatever complex type Redis returns. |
Name | Type | Description |
---|---|---|
command |
(string | number | boolean )[] |
The command to execute. |
Promise
<TResult
>
The raw results of calling the Redis command.
▸ fetchRepository<TEntity
>(schema
): Repository
<TEntity
>
Creates a repository for the given schema.
Name | Type | Description |
---|---|---|
TEntity |
extends Entity <TEntity > |
The entity type for this {@lin Schema} and Repository. |
Name | Type | Description |
---|---|---|
schema |
Schema <TEntity > |
The schema. |
Repository
<TEntity
>
A repository for the provided schema.
▸ isOpen(): boolean
boolean
Whether a connection is already open
▸ open(url?
): Promise
<void
>
Open a connection to Redis at the provided URL.
Name | Type | Default value | Description |
---|---|---|---|
url |
string |
'redis://localhost:6379' |
A URL to Redis as defined with the IANA. |
Promise
<void
>