joojle-db-files-v2
v0.1.1
Published
A simple database that allows low-level data manipulation. It stores data as files, rather than in a format. More In The README
Downloads
4
Maintainers
Readme
Joojle DB Files V.2
joojle DB Files V.2 is super-simple psuedo database that allows you to store simple structures. It is not meant to store data like a traditional database and you will probably need one to complement this
Motivations
Despite being suuuuper-simple, joojle db files was not as easy to use as it could have been, so, I decided to create a second version of the module, without forsaking the development on the previous one
Use Cases
This has been made entirely as a toy-project and is not a fully featured database. It lacks some important features, but I plan to add them in due corse of time. In the meanwhile, I continue to work on my main project, that uses this. For most traditional cases, use other databases, but if you find yourself in a situation like mine, feel free to uses it. Most importantly, please make sure to test this your project thoroughly.
Usage
Install the entire package
$npm i --save joojle-db-files
This installs the package entire server AND driver
To run the server execute the start.sh
or start.cmd
command based upon your OS
One the server starts, use import an use the driver into your project like so
const { createDb } = require("joojle-db-files")
const db = createDb() // or with createDb({ auth:{...data from createUser Function}, connection:{...self_explanitory} })
Then use this db to create machines, drive, and datafiles
//index.js
/** Create Drive */
db.setDefaultMachine("m2") // not necessary
db.setDefaultDrive("d2") // not necessary
// if degault machine is not set, you need to pass it in as {machine: "..."}
const res1 = await db.createMachine()
// same thing for drive + machine also needed
const res2 = await db.createDrive()
// same thing here too!
const res3 = await db.createData({ data: "Hello World Def" })
Return Values
The functions all return a Promise, resolving to an object with a "success"
value, either a true
or a false
. If false then the function failed
In case of the readDrive
and readData
functions, a data
key is also present and contains the requested data
if setDefaultMachine and drive have been called, no need to provide them is needed in any of the functions. If only these two or one of them are needed, the object can be completely ommited
Function Name | Parameters |Description |Return Values --------------|---------------------------------------------|-------------------------------------------------------------------------------------------|-------------------- createMachine | {machine: "..."} | Creates A Machine With The Given Name Or The Default Name | { success: boolean } createDrive | {machine: "...", drive: "..."} | Creates A Drive With Given Or Default Name In The Given Machine Or Default Machine | { success: boolean } readDrive | {machine: "...", drive: "..."} | Reads A Drive With Given Or Default Name In The Given Machine Or Default Machine | { success: boolean, data: [string] } createData | {machine: "...", drive: "...", data: ""} | Creates A Data File | { success: boolean, id: string } readData | {machine: "...", drive: "...", id: ""} | Reads A Data File In Drive With Given ID | { success: boolean, data: string }