Skip to content

Releases: XenKys/belin.db

belin.db@1.0.6

31 Dec 12:20
Compare
Choose a tag to compare

belin.db

An NPM package for creating a local JSON-based database

Changes

  • Created filter, find, map, random, size, some and sort methods (d6579a7)

belin.db@1.0.5

08 Oct 15:30
Compare
Choose a tag to compare

belin.db

An NPM package for creating a local JSON-based database

Changes

  • Improved typings (4243df7)
  • Fixed push and pull methods (cb5a581)
  • Imported Database as a type (c0abc7b)
  • Fixed unprovided key error (0b0266e)
  • Typed base delete, get and set methods (894b67f)
  • Fixed push method (5a4d143)
  • Updated all errors messages (d52ccd4)
  • Updated README (02a9d9c)

belin.db@1.0.4

13 Aug 17:46
Compare
Choose a tag to compare

belin.db

An NPM package for creating a local JSON-based database

What has changed?

  • Fixed fake undefined values (fdd2bc6)

belin.db@1.0.3

05 Mar 17:15
Compare
Choose a tag to compare

belin.db

An NPM package for creating a local JSON-based database

What are the changes?

  • Updated the path parameter

Getting started

  • Install the package
npm install belin.db
  • Import the installed package
const { Database } = require("belin.db");
  • Init the database
const db = new Database(
  "./database.json", // The file path for the JSON file to save the data
  {
    separator: ".", // The separator symbol that you will use to split the data
    belowZero: false, // If the numbers on the saved data can go below 0
  }
);

Database options

Key Value type Description Default value Optional?
path String The file path for the JSON file to save the data ./database.json Yes
separator String The separator symbol that you will use to split the data . Yes
belowZero Boolean If the numbers on the saved data can go below 0 false Yes

All Methods

set(key, value)

Set a value to a key

get(key)

Get the value of a key

delete(key)

Delete the value of a key

has(key)

Check if a key exists

all()

Get the JSON file

clear()

Delete all saved data

importFrom(path)

Import data from another JSON file

push(key, item)

Push an item into an array

pull(key, item)

Pull an item from an array

add(key, number)

Add a number to a key value

remove(key, number)

Remove a number from a key value

Example

const { Database } = require("belin.db");
const db = new Database("./database/test.json", {
  separator: "_",
  belowZero: true,
});

db.set("a_b_c", "value"); // { "a": { "b": { "c": "value" }}}
db.get("a"); // { "b": { "c": "value" }}
db.delete("a_b_c"); // { "a": { "b": {}}}
db.has("a_b_c"); // true
db.all(); // { "a": { "b": { "c": "value" }}}
db.clear(); // {}
db.importFrom("./file.json"); // {}
db.push("a_b", "item"); // { "a": { "b": ["item"] }}
db.pull("a_b", "item"); // { "a": { "b": [] }}
db.add("a_c", 4); // { "a": { "b": [] }, { "c": 4 }}
db.remove("a_c", 2); // { "a": { "b": [] }, { "c": 2 }}

belin.db@1.0.2

28 Jan 19:54
Compare
Choose a tag to compare

belin.db

An NPM package for creating a local JSON-based database

What are the changes?

  • Rewrited in TypeScript
  • Renamed the replace method to importFrom
  • Added [belin.db] to all errors
  • Exported the Database class as not default
  • Fixed some returns type and value
  • Fixed some function parameter name
  • Fixed the readme

Getting started

  • Install the package
npm install belin.db
  • Import the installed package
const { Database } = require("belin.db");
  • Init the database
const db = new Database({
  path: "./database.json", // The file path for the JSON file to save the data
  separator: ".", // The separator symbol that you will use to split the data
  belowZero: false, // If the numbers on the saved data can go below 0
});

Database options

Key Value type Description Default value Optional?
path String The file path for the JSON file to save the data ./database.json Yes
separator String The separator symbol that you will use to split the data . Yes
belowZero Boolean If the numbers on the saved data can go below 0 false Yes

All Methods

set(key, value)

Set a value to a key

get(key)

Get the value of a key

delete(key)

Delete the value of a key

has(key)

Check if a key exists

all()

Get the JSON file

clear()

Delete all saved data

importFrom(path)

Import data from another JSON file

push(key, item)

Push an item into an array

pull(key, item)

Pull an item from an array

add(key, number)

Add a number to a key value

remove(key, number)

Remove a number from a key value

Example

const { Database } = require("belin.db");
const db = new Database({
  fileName: "./database/test.json",
  separator: "_",
  belowZero: true,
});

db.set("a_b_c", "value"); // { "a": { "b": { "c": "value" }}}
db.get("a"); // { "b": { "c": "value" }}
db.delete("a_b_c"); // { "a": { "b": {}}}
db.has("a_b_c"); // true
db.all(); // { "a": { "b": { "c": "value" }}}
db.clear(); // {}
db.importFrom("./file.json"); // {}
db.push("a_b", "item"); // { "a": { "b": ["item"] }}
db.pull("a_b", "item"); // { "a": { "b": [] }}
db.add("a_c", 4); // { "a": { "b": [] }, { "c": 4 }}
db.remove("a_c", 2); // { "a": { "b": [] }, { "c": 2 }}

belin.db@1.0.1

06 Jan 16:00
Compare
Choose a tag to compare

belin.db

An NPM package for creating a local JSON-based database

What are the changes?

  • Now you can set multiple keys to an object
  • Now when you use the has method with the belowZero option enabled it will print a warning in the console
[belin.db] The belowZero option is set to true, this may return false if the key's value is 0
  • Now the replace method will give you an error if the path does not end with the .json extension
  • Added descriptions to the Database class and its methods

Getting started

  • Install the package
npm install belin.db
  • Import the installed package
const Database = require("belin.db");
  • Init the database
const db = new Database({
  path: "./database.json", // The file path for the JSON file to save the data
  separator: ".", // The separator symbol that you will use to split the data
  belowZero: false, // If the numbers on the saved data can go below 0
});

Database options

Key Value type Description Default value Optional?
path String The file path for the JSON file to save the data ./database.json Yes
separator String The separator symbol that you will use to split the data . Yes
belowZero Boolean If the numbers on the saved data can go below 0 false Yes

All Methods

set(key, value)

Set a value to a key

get(key)

Get the value of a key

delete(key)

Delete the value of a key

has(key)

Check if a key exists

all()

Get the JSON file

clear()

Delete all saved data

replace(path)

Replace all saved data with that of another JSON file

push(key, item)

Push an item into an array

pull(key, item)

Pull an item from an array

add(key, number)

Add a number to a key value

remove(key, number)

Remove a number from a key value

Example

const Database = require("belin.db");
const db = new Database({
  fileName: "./test/data.json",
  separator: "_",
  belowZero: true,
});

db.set("a_b_c", "value"); // { "a": { "b": { "c": "value" }}}
db.get("a"); // { "b": { "c": "value" }}
db.delete("a_b_c"); // { "a": { "b": {}}}
db.has("a_b_c"); // true
db.all(); // { "a": { "b": { "c": "value" }}}
db.clear(); // {}
db.replace("./file.json"); // {}
db.push("a_b", "item"); // { "a": { "b": ["item"] }}
db.unpush("a_b", "item"); // { "a": { "b": [] }}
db.add("a_c", 4); // { "a": { "b": [] }, { "c": 4 }}
db.remove("a_c", 2); // { "a": { "b": [] }, { "c": 2 }}

belin.db@1.0.0

04 Jan 17:17
Compare
Choose a tag to compare

belin.db

An NPM package for creating a local JSON-based database

Getting started

  • Install the package
npm install belin.db
  • Import the installed package
const Database = require("belin.db");
  • Init the database
const db = new Database({
  path: "./database.json", // The file path for the JSON file to save the data
  separator: ".", // The separator symbol that you will use to split the data
  belowZero: false, // If the numbers on the saved data can go below 0
});

Database options

Key Value type Description Default value Optional?
path String The file path for the JSON file to save the data ./database.json Yes
separator String The separator symbol that you will use to split the data . Yes
belowZero Boolean If the numbers on the saved data can go below 0 false Yes

All Methods

set(key, value)

Set a key and a value

get(key)

Get a key with its values

delete(key)

Delete the key with its values

has(key)

Check if has the key

all()

Get all the keys with them values

clear()

Delete all keys with them values

replace(path)

Replace the saved data in the file with the data from another file

push(key, element)

Add an element to the key

pull(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

Example

const Database = require("belin.db");
const db = new Database({
  fileName: "./test/data.json",
  separator: "_",
  belowZero: true,
});

db.set("a_b_c", "value"); // { "a": { "b": { "c": "value" }}}
db.get("a"); // { "b": { "c": "value" }}
db.delete("a_b_c"); // { "a": { "b": {}}}
db.has("a_b_c"); // true
db.all(); // { "a": { "b": { "c": "value" }}}
db.clear(); // {}
db.replace("./file.json"); // {}
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 }}