joojle-db-files
v0.0.5
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
17
Maintainers
Readme
Joojle DB Files
joojle DB Files 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
I wanted to create a simple file-storage solution that would allow users to upload files. I was using Next-js with vanilla js, and mongoose to access mongo-db (my primary database). However, i found a lack of existing solutions to connect to Mongo's Grid-Fs in a simple and elegent manner. Whats more, is that i did not want to store all the users' files onto my own server (which ran the next instance). So i decided to re-invent the wheel and produce Joojle-db-fs.
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 }