1.2.0 • Published 2 years ago

xenkysdb v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

5.0.0

3 years ago

4.0.0

3 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago