file-easy-database

1.0.0 • Public • Published

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()

Thank You For Using

Package Sidebar

Install

npm i file-easy-database

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

23 kB

Total Files

10

Last publish

Collaborators

  • filipinoakoyoutube