Skip to content
On this page

metronom / Modules / Metronom / default

Class: default

Metronom.default

Metronom model creator

Table of contents

Properties

Constructors

Methods

Properties

redisClientOptions

Optional redisClientOptions: RedisClientOptions<Record<string, never>, Record<string, never>>

Defined in

Metronom.ts:20


log

Optional log: boolean | LogLevels

Defined in

Metronom.ts:22


#redisClient

Private #redisClient: null | IRedisAdaptor

Defined in

Metronom.ts:24

Constructors

constructor

new default(options)

Base Metronom object. You can create new metronom instance with diffirent options like redis url.

Parameters

NameTypeDescription
optionsMetronomOptionsredis client settings

Methods

define

define(schema, keyPrefix?, modelOptions?): default

Create metronom model from this Metronom object

Parameters

NameTypeDefault valueDescription
schemaSchemaundefinedRecord's key-value schema
keyPrefixstring'object'Record unique key's prefix. "users:1234" --> "keyPrefix:keyUnique"
modelOptions?ModelOptionsundefined-

Returns

default

new record of Model


setKey

setKey(key, value): Promise<string>

Create String key or update if it exist. Redis's "SET" command

Parameters

NameTypeDescription
keystringredis key
valueanyvalue

Returns

Promise<string>

it return "OK" if the process done


getKey

getKey(key): Promise<null | string>

Read String key Redis's "GET" command

Parameters

NameTypeDescription
keystringRedis key

Returns

Promise<null | string>

if the key is exist it return the value else return null

Released under the MIT License.