Class: db

db(engine, config)

Main Node.js pmemkv class, it provides functions to operate on data in database. If an error/exception is thrown from a method it will contain *status* variable. Possible statuses are enumerated in constants.status.

Constructor

new db(engine, config)

Creates an instance of db.
Parameters:
Name Type Description
engine string Name of the engine to work with.
config object JSON like config with parameters specified for the engine.
Source:
Throws:
on any failure.
Type
Error

Members

count_all

Returns number of currently stored elements in db.
Source:

stopped

Returns value of *stopped* property.
Source:

Methods

count_above(key) → {number|object}

Returns number of currently stored elements in db, whose keys are greater than the given *key*.
Parameters:
Name Type Description
key string sets the lower bound of counting.
Source:
Throws:
on any failure.
Type
Error
Returns:
Number of records in db matching query or empty Value() if error occurred.
Type
number | object

count_below(key) → {number|object}

Returns number of currently stored elements in db, whose keys are less than the given *key*.
Parameters:
Name Type Description
key string sets the upper bound of counting.
Source:
Throws:
on any failure.
Type
Error
Returns:
Number of records in db matching query or empty Value() if error occurred.
Type
number | object

count_between(key1, key2) → {number|object}

Returns number of currently stored elements in db, whose keys are greater than the *key1* and less than the *key2*.
Parameters:
Name Type Description
key1 string sets the lower bound of counting.
key2 string sets the upper bound of counting.
Source:
Throws:
on any failure.
Type
Error
Returns:
Number of records in db matching query or empty Value() if error occurred.
Type
number | object

exists(key) → {boolean}

Checks existence of record with given *key*.
Parameters:
Name Type Description
key string record's key to query for.
Source:
Throws:
on any failure.
Type
Error
Returns:
True if record with given key exists, False otherwise.
Type
boolean

get(key) → {object}

Gets value of record with given *key*.
Parameters:
Name Type Description
key string record's key to query for.
Source:
Throws:
on any failure.
Type
Error
Returns:
string with value stored for this key, env.Undefined() if not found, or empty Value() if error.
Type
object

get_above(key, callback)

Executes function for every record stored in db, whose keys are greater than the given *key*.
Parameters:
Name Type Description
key string sets the lower bound for querying.
callback function function to be called for each returned element.
Source:
Throws:
on any failure.
Type
Error

get_all(callback)

Executes function for every record stored in db.
Parameters:
Name Type Description
callback function function to be called for every element stored in db.
Source:
Throws:
on any failure.
Type
Error

get_below(key, callback)

Executes function for every record stored in db, whose keys are less than the given *key*.
Parameters:
Name Type Description
key string sets the upper bound for querying.
callback function function to be called for each returned element.
Source:
Throws:
on any failure.
Type
Error

get_between(key1, key2, callback)

Executes function for every record stored in db, whose keys are greater than the *key1* and less than the *key2*.
Parameters:
Name Type Description
key1 string sets the lower bound for querying.
key2 string sets the upper bound for querying.
callback function function to be called for each returned element.
Source:
Throws:
on any failure.
Type
Error

get_keys(callback)

Executes function for every record stored in db. Callback is called only with the key of each record.
Parameters:
Name Type Description
callback function function to be called for every element stored in db. It has only one param - key (for each returned element).
Source:
Throws:
on any failure.
Type
Error

get_keys_above(key, callback)

Executes function for every record stored in db, whose keys are greater than the given *key*. Callback is called only with the key of each record.
Parameters:
Name Type Description
key string sets the lower bound for querying.
callback function function to be called for each returned element. It has only one param - key (for each returned element).
Source:
Throws:
on any failure.
Type
Error

get_keys_below(key, callback)

Executes function for every record stored in db, whose keys are less than the given *key*. Callback is called only with the key of each record.
Parameters:
Name Type Description
key string sets the upper bound for querying.
callback function function to be called for each returned element. It has only one param - key (for each returned element).
Source:
Throws:
on any failure.
Type
Error

get_keys_between(key1, key2, callback)

Executes function for every record stored in db, whose keys are greater than the *key1* and less than the *key2*. Callback is called only with the key of each record.
Parameters:
Name Type Description
key1 string sets the lower bound for querying.
key2 string sets the upper bound for querying.
callback function function to be called for each returned element. It has only one param - key (for each returned element).
Source:
Throws:
on any failure.
Type
Error

put(key, value)

Inserts a key-value pair into pmemkv database.
Parameters:
Name Type Description
key string record's key; record will be put into database under its name.
value string data to be inserted into this new database record.
Source:
Throws:
on any failure.
Type
Error

remove(key) → {boolean}

Removes from database record with given *key*.
Parameters:
Name Type Description
key string record's key to query for, to be removed.
Source:
Throws:
on any failure.
Type
Error
Returns:
True if pmemkv returned status OK, False if status NOT_FOUND.
Type
boolean

stop()

Stops the database.
Source: