oj-kvdb
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

KVDB (Key Value Database)

A simple nodejs database solution. Data stays in memory for fast access and stays synced with a JSON file for persistency.

constructor

constructor<T>(location?: string, syncThreshold: number = 200): KVDB<T>

The location points to a JSON file. It will create the file if it doesn't exist. The syncThreshold is the debounce threshold that the persistent JSON file gets written to. Pass a 0 to disable debouncing and write directly after each database edit.

const db = new KVDB<string>("D:/projectData/data.json", 0)

set

set(key: string, value: T): string

set("myKey", "my data") // "myKey"
set("otherKey", "some other data") // "otherKey"

get

get(key: string): T

get("myKey") // "my data"
get("otherKey") // "some other data"

has

has(key: string): boolean

has("myKey") // true
has("bar") // false

getAll

getAll(): [string, string][]

getAll() // [["myKey", "my data"], ["otherKey", "some other data"]]

Package Sidebar

Install

npm i oj-kvdb

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

6.97 kB

Total Files

6

Last publish

Collaborators

  • orange-juice