file-easy-database
v1.0.0
Published
Save a file to json or in mongodb
Downloads
1
Maintainers
Readme
File Database
Store your file in a json or in a mongodb
Note
This is just a beta version for now. You will get errors for now
Mongoose File Database
Mongoose sometimes slow and sometimes fast
const { MongooseFileDb } = require('file-easy-database')
let filedb = new MongooseFileDb('your mongo db url')
async function awaitAll() {
// I more recommend using await in every method for less errors
await filedb.set('./myfile.tosave') // im awaiting it because sometimes .set is late
// @note - The identifier for the file is the filename
console.log(await filedb.list()) // check if the list
console.log(await filedb.has('myfile.tosave')) // check if the file your saved is actually saved in the database
await filedb.get('myfile.tosave', './myfile.recieved')
// Filename identifier ^ Output File Name ^
await filedb.delete('myfile.tosave') // delete these specific file in the database
await filedb.reset() // reset your filedb
}
awaitAll()
Json File Db
Json depends on your storage
const { JsonFileDb } = require('file-easy-database')
let filedb = new JsonFileDb('./mydb.json')
// This works like the mongodb one but fast
// And dont need awaits
filedb.set('./myfile.tosave')
console.log(filedb.list())
console.log(filedb.has('myfile.tosave'))
filedb.get('myfile.tosave', 'myfile.recieved')
filedb.delete('myfile.tosave')
filedb.reset()
Methods
.set(filepath, forceoverwrite)
.get(filename, outputpath)
.delete(filename)
.has(filename)
.list()
.reset()