0.0.11 • Published 2 years ago

bgraphdb v0.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

B-Graph DB

Javascript database. Memory DB with nested b-graph (B-Tree).

Please use version > 0.0.9

From v0.0.10, db structure use String instead of object for a storage(bgraph) of label to avoid JSON circular iteration problem.

▶️ install

npm i bgraphdb

👩‍🎓 Tutorial

Most of Case

const bgraphdb = new BGraphDB();
bgraphdb.insertLabel("test1");
bgraphdb.insertLabel("test2");
bgraphdb.insertData("test1", "1", "1");
bgraphdb.insertData("test1", "2", "2");
bgraphdb.insertData("test1", "3", "3");
bgraphdb.insertData("test1", "4", "4");
bgraphdb.insertData("test1", "5", "5");
bgraphdb.deleteData("test1", "6");
bgraphdb.deleteLabel("test2");

This database stays in the memory. So if you want to maintain them, you need to store them in the persistent storage. The database can be serialized and the serialized database can be stored by indexedDB or using file system from node.js.

Don't store bigger than what hardware can handle.

It would be good to maintain read and write a file speed under 1 second for desktop apps. For example: If you target HDD users, less than 80mb size of serialized database. If you target SSD users, less than 450mb size of serialized database.

Another good option is read and write only when your apps need to. For example: Read a db file only when your app is strating. Write a db file only before your app is closing. Or only when user decides to write a db file.

📖 Simple document

functioninsertLabel(label)
descriptionThis function is for reserving place of 1 b-graph for storing data. This is like name of category or page. And data will be stored under that name (label)
arg: labelstring, name of b-graph to store data
returntrue for inserting label otherwise false
functionupdateLabel(oldLabel, newLabel)
descriptionThis function is for updating name of label.
arg: oldLabelstring, old name of b-graph to store data
arg: newLabelstring, new name of b-graph to store data
returnfalse for failure of updating value, true for success
functiondeleteLabel(label)
descriptionThis function deletes label. Which mean it removes all of data under the name of label.
arg: labelstring, name of b-graph to store data
returndoes not exist yet
functioninsertData(label, key, value)
descriptionThis function inserts the key and value inside of b-graph of the label
arg: labelstring, name of b-graph to store data
arg: keystring, name of value
arg: valueanything but recommend the value that can be JSON.stringfy()
returnfalse for failure of inserting data, true for success
functionupdateData(label, key, value)
descriptionThis function updates value of the key inside of b-graph of label
arg: labelstring, name of b-graph to store data
arg: keystring, name of value
arg: valuenew value. anything but recommend the value that can be JSON.stringfy()
returnfalse for failure of updating data, true for success
functiondeleteData(label, key)
descriptionThis function deletes the data of key inside of b-graph of label
arg: labelstring, name of b-graph to store data
arg: keystring, name of value
returnfalse for failure of deleting data, true for success
functionsearch(label, key)
descriptionThis function searches key inside of b-graph of label and return the value of key
arg: labelstring, name of b-graph to store data
arg: keystring, name of value
returnunidentified for failure of searching data, value for success
functionsearchRange(label, key, total, position = 0)
descriptionThis function searches data and returns multiple number of data from the position
arg: labelstring, name of b-graph to store data
arg: keystring, name of value
arg: totalnumber, number of data from the position
arg: positionnumber, the position where it start to store data into list. This let us skip first number of data from the where key is.
returnunidentified for wrong label and key. list of data for success. else empty list
functionsearchRangeBackward(label, key, total, position = 0)
descriptionThis function searches data and returns multiple number of data from the position. Adds data backward.
arg: labelstring, name of b-graph to store data
arg: keystring, name of value
arg: totalnumber, number of data from the position
arg: positionnumber, the position where it start to store data into list. This let us skip first number of data from the where key is.
returnunidentified for wrong label and key. list of data for success. else empty list
functionsearchLabelContains(substring, total, position, lastKey)
descriptionThis function is for finding list of labels that contains substring.
arg: substringstring
arg: totalnumber, number of labels to grab
arg: positionnumber, number to skip labels
arg: lastKeystring, last label where it should start search from
returnreturn list of label (empty list as well)
functionsearchLabelContainsOnlyLabel(substring, total, position, lastKey)
descriptionThis function is for finding list of labels that contains substring.
arg: substringstring
arg: totalnumber, number of labels to grab
arg: positionnumber, number to skip labels
arg: lastKeystring, last label where it should start search from
returnreturn list of label (empty list as well)
functionsearchKeyContains(label, substring, total, position, lastKey)
descriptionThis function is for finding list of data that its key contains substring.
arg: labelstring, name of b-graph to store data
arg: substringstring
arg: totalnumber, number of data to grab
arg: positionnumber, number to skip data
arg: lastKeystring, last key where it should start search from
returnreturn list of data (empty list as well)
functionsearchValueContains(label, substring, total, position, lastKey)
descriptionThis function is for finding list of data that its value contains substring.
arg: labelstring, name of b-graph to store data
arg: substringstring
arg: totalnumber, number of data to grab
arg: positionnumber, number to skip data
arg: lastKeystring, last key where it should start search from
returnreturn list of data (empty list as well)
functiongetStart(label)
descriptionThis function is for finding list of data that its value contains substring.
arg: labelstring, name of b-graph to store data
returnreturn first data,
functiongetEnd(label)
descriptionThis function is for finding list of data that its value contains substring.
arg: labelstring, name of b-graph to store data
returnreturn last data
functiongetAllLabels()
descriptionThis function returns a list of labels
returnreturn array list
functiongetAllKeysFromLabel(label)
descriptionThis function returns a list of all key from label
arg: labelstring, name of b-graph to store data
returnreturn array list
functiongetAllValuesFromLabel(label)
descriptionThis function returns a list of all value from label
arg: labelstring, name of b-graph to store data
returnreturn array list
functiongetAllFromLabel(label)
descriptionThis function returns a list of all data from label
arg: labelstring, name of b-graph to store data
returnreturn array list
functionserialize()
descriptionserialize database. it can be stored by indexedDB or using file system from node.js
returnstring, serialized database
functiondeserialize(string)
descriptiondeserialize serialized database.
arg: stringstring, serialized database

👨‍💻 Author

Victor Chanil Park

💯 License

MIT, See LICENSE.

0.0.10

2 years ago

0.0.11

2 years ago

0.0.3

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago