Installation
master: npm i DeltaRade/jndb
stable: npm i jndb
Docs
class Connection
constructor(table, options)
- Parameters:
table
—string
—{{path:'.',fetchAll:false}}
—
get count()
gets the amount of entries from the database directly
delete(key)
deletes a key from the database
- Parameters:
key
—string|number
— - Returns:
this
—
has(key)
checks if the database has a value
- Parameters:
key
—string|number
— - Returns:
boolean
—
insert(key, value)
insert a value into the database
- Parameters:
key
—string|number
—value
—*
—
- Returns:
this
—
fetch(key)
fetch a value from the database and adds it to this.
- Parameters:
key
—string|number
— - Returns:
*
—
fetchArray()
fetch all table objects from the database directly and inserts them into an array in the form of:[ { key:string|number,value:any } ]
- Returns:
Array<{}>
—
fetchAll()
fetch all table objects from the database directly
- Returns:
{}
—
compress()
compresses the database into a separate file called jndb.dat
- Returns:
CompressedJSON
—
uncompress()
gets the compressed data from jndb.bat
(if it exists)
- Returns:
CompressedJSON
—
Usage
const jndb = ;const x = ;// select the table that is going to be usedx; console;xconsole // returns undefined if value cannot be obtainedconsole //fetch table items into an objectlet obj=x;forlet i in obj console // fetch table items as an array of objectsconsole // search the table for specific property matching// returns an array of objects containing key and valuelet kv=xconsole //compress data into jndb.datx //return uncompressed data from that fileconsole
Issues
You can post issues here.