A simple JSON database in a npm package.
npm i xenkysdb
const Database = require("xenkysdb")
const db = new Database()
Set a key and a value.
Get a key with its values.
Check if has the key.
Get all the keys with them values.
Delete the key with its values.
Delete all keys with them values.
Add an element to the key.
Remove an element from the key.
Add a number to the key.
Remove a number from the key.
const Database = require("xenkysdb")
const db = new Database({
name: "storage", // The optional name of the json file, the default name is storage
directory: "databases", // The optional name of the folder where the json files will be created
separator: "." // The optional separator to switch between keys, the default separator is .
})
db.set("a.b.c", "value") // { "a": { "b": { "c": "value" }}}
db.get("a") // { "b": { "c": "value" }}
db.has("a.b.c") // true
db.all() // { "a": { "b": { "c": "value" }}}
db.delete("a.b.c") // { "a": { "b": {}}}
db.clear() // {}
db.push("a.b", "element") // { "a": { "b": ["element"] }}
db.unpush("a.b", "element") // { "a": { "b": [] }}
db.add("a.c", 4) // { "a": { "b": [] }, { "c": 4 }}
db.remove("a.c", 2) // { "a": { "b": [] }, { "c": 2 }}