Home Reference Source Test Repository
import {Hash} from 'webdismay/src/index.js'
public class | source

Hash

Methods for manipulating a hash on the redis server

Constructor Summary

Public Constructor
public

Instantly create a hash handler associated with a specific hash, via its key, sends no requests to the server until a method is called.

Member Summary

Public Members
public

k: *

Method Summary

Public Methods
public

delete a field from the hash (via HDEL)

public

delete the entire hash (via DEL)

public

return the selected field from the hash

public

returns the entire hash as a javascript Object, and will return {} if the hash does not exist (via HGETALL)

public

incrBy(f: *, amount: *): Promise<number, Error>

add amount to value of field f and return the new value (via HINCRBY)

public

incrByFloat(f: *, amount: *): Promise<number, Error>

add amount to value of field f and return the new value (via HINCRBYFLOAT)

public

list the fields of this hash (via HKEYS)

public

number of fields in the hash (via HLEN)

public

set(obj: *): Promise<Array, Error>

set all fields of a hash sourced from a Javascript object, deletes entire hash first and recreates (via DEL and HMSET).

public

set an undefined field to a value, but has no effect if field exists (via HSETNX)

public

update(obj: *): Promise<Array, Error>

merges fields and values from a Javacript object into the hash (via HMSET)

public

list the values of this hash (via HVALS)

Public Constructors

public constructor(k: string) source

Instantly create a hash handler associated with a specific hash, via its key, sends no requests to the server until a method is called.

Params:

NameTypeAttributeDescription
k string

Key where a Hash is stored, or to be stored, on the server

Public Members

public k: * source

Public Methods

public del(f: string): Promise<number, Error> source

delete a field from the hash (via HDEL)

Params:

NameTypeAttributeDescription
f string

name of field to be deleted

Return:

Promise<number, Error>

response is 1 if field is deleted, 0 if non-existent

public deleteAll(): Promise<number, Error> source

delete the entire hash (via DEL)

Return:

Promise<number, Error>

response is 1 if the hash was deleted, 0 if not

public get(f: string): Promise<string, Error> source

return the selected field from the hash

Params:

NameTypeAttributeDescription
f string

The field name

Return:

Promise<string, Error>

response is the requested field's value

public getAll(): Promise<Object, Error> source

returns the entire hash as a javascript Object, and will return {} if the hash does not exist (via HGETALL)

Return:

Promise<Object, Error>

response is the requested data

public incrBy(f: *, amount: *): Promise<number, Error> source

add amount to value of field f and return the new value (via HINCRBY)

Params:

NameTypeAttributeDescription
f *

field name

amount *

Integer amount to add

Return:

Promise<number, Error>

response is the new value

public incrByFloat(f: *, amount: *): Promise<number, Error> source

add amount to value of field f and return the new value (via HINCRBYFLOAT)

Params:

NameTypeAttributeDescription
f *

field name

amount *

Floating-point amount to add

Return:

Promise<number, Error>

response is the new value

public keys(): Promise<string[], Error> source

list the fields of this hash (via HKEYS)

Return:

Promise<string[], Error>

response is array list of fields

public len(): Promise<number, Error> source

number of fields in the hash (via HLEN)

Return:

Promise<number, Error>

response is number of fields in the hash

public set(obj: *): Promise<Array, Error> source

set all fields of a hash sourced from a Javascript object, deletes entire hash first and recreates (via DEL and HMSET). Clients reading at the same time may get either an empty object or the entire object.

Params:

NameTypeAttributeDescription
obj *

Object containing fields and values to set hash

Return:

Promise<Array, Error>

status response

public setnx(f: string, v: string): Promise<number, Error> source

set an undefined field to a value, but has no effect if field exists (via HSETNX)

Params:

NameTypeAttributeDescription
f string

The field name

v string

The field value (might be a stringified object, etc.)

Return:

Promise<number, Error>

response is 1 if field f set to v, 0 if not

public update(obj: *): Promise<Array, Error> source

merges fields and values from a Javacript object into the hash (via HMSET)

Params:

NameTypeAttributeDescription
obj *

Object containing fields and values to merge into hash

Return:

Promise<Array, Error>

status response

public vals(): Promise<string[], Error> source

list the values of this hash (via HVALS)

Return:

Promise<string[], Error>

response is array list of values