xenkysdb

1.2.0 • Public • Published

xenkysdb

A simple JSON database in a npm package.

Installation

npm i xenkysdb

Setup

const Database = require("xenkysdb")
const db = new Database()

All Methods

set(key, value)

Set a key and a value.

get(key)

Get a key with its values.

has(key)

Check if has the key.

all()

Get all the keys with them values.

delete(key)

Delete the key with its values.

clear()

Delete all keys with them values.

push(key, element)

Add an element to the key.

unpush(key, element)

Remove an element from the key.

add(key, number)

Add a number to the key.

remove(key, number)

Remove a number from the key.

Examples

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 }}

Package Sidebar

Install

npm i xenkysdb

Weekly Downloads

1

Version

1.2.0

License

ISC

Unpacked Size

9.79 kB

Total Files

14

Last publish

Collaborators

  • xenkys_npm