A super-simple key-value store. This means it's equivalent to a JS Object: every entry in the database has a name (the key) and a value (the value).
const database = require("kvaluedb");
No need to do anything!
That's right, importing the module automatically a file called database.db
for the database! If such a file is already there, then the contents of that file are assumed to be the contents of the database.
database.list()
returns the entire database.
If you want to get just a single entry of the database, use database.get(<key>)
to get the value of a specific entry. If the entry in question is not in the database, it will throw an error.
database.set(<key>, <value>)
adds an entry with key <key>
and value <value>
. If an entry with key <key>
is already in the database, it will overwrite it's value.
database.delete(<key>)
deletes the entry with key <key>
. If the entry in question is not in the database, it will throw an error.
database.has(<key>)
checks if an entry exists with key <key>
.