0.1.28 • Published 3 years ago

jason.db v0.1.28

Weekly downloads
21
License
MIT
Repository
github
Last release
3 years ago

jason.db (jason's db) · CI

DO NOT USE THIS IT WAS MADE AS A JOKE

This package stores JSON data which is prone to potential corruption and data loss. I strongly suggest you do not use it. If you want an easy storage solution please take a look at enmap.

Enmap


I was bored, so I made this garbage JSON database. Don't use it unless you are just staring a project and need a temperary database. It isn't very fast and is very memory inefficient.


Example:

const jasonDB = require("jason.db");
const DB = new jasonDB("db.json", { caching: true, renameFile: false });

DB.collection("data").set("data", "value");
DB.collection("data").push("dataArray", "value");
DB.collection("data").set("object.data", "nested value");

console.log(DB.collection("data").has("data")); // true
console.log(DB.collection("data").get("data")); // value
console.log(DB.collection("data").get("data")); // ["value"]
console.log(DB.collection("data").get("object")); // { data: "nested value" }
console.log(DB.collection("data").get()); // { data: 'value', dataArray: [ 'value' ], object: { data: 'nested value' } }

DB.clear(true);
console.log(DB.collection("data").get()); // {}

Options

Options passed into the DB

OptionTypeDefaultDescription
renameFilebooleantrueEnable renaming the file, replacing all occurances of "json" with "jason"
writeFilebooleanfalseEnable writing the file path, may cause random files to appear

Options passed into the Collection

OptionTypeDefaultDescription
cachingbooleanfalseEnables caching the entire json file in memory

DB

DB.collection()

DB.collection(name)

returns - Collection

Returns a collection, if none exists with the name, it will be created.

  • name (sring) - The name of the collection.

DB.clear()

DB.clear(boolean)

returns - boolean

Returns a boolean, the success of the clear.

  • boolean (boolean) - The name of the collection.

Collection

Collection.push()

Collection.push(key, data)

returns - boolean

Returns a boolean, the success of the save.

  • key (string | number) - The key of the data.
  • data (any) - The data to push to the array.

Collection.set()

Collection.set(key, data)

returns - boolean

Returns a boolean, the success of the save.

  • key (string | number) - The key of the data.
  • data (any) - The data to save.

Collection.get()

Collection.get(key)

returns - any

Returns the data set to the key.

  • key (string | number) - The key of the data.

Collection.has()

Collection.push(key, data)

returns - boolean

Returns a boolean, if the collection has data with that key.

  • key (boolean) - The key of the data.

Contributiors

flazepe - Code for nested objects

0.1.28

3 years ago

0.1.27

3 years ago

0.1.26

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.23

3 years ago

0.1.20

3 years ago

0.1.21

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.14

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.6

3 years ago

0.1.0

3 years ago