easy-bdd
Version:
Manipulez les db facilement
47 lines (38 loc) • 974 B
JavaScript
const low = require("lowdb")
const fileSync = require('lowdb/adapters/FileSync')
class DB {
constructor(files) {
this.files = files
this.FS = new fileSync(this.files)
this.db = low(this.FS)
this.json = this.db
}
Read() {
this.json = this.json.value()
return this.json
}
Get(args) {
const get = this.json.get(args)
this.json = get
return this
}
Find(args) {
const find = this.json.find(args)
this.json = find
return this
}
Push(args) {
const push = this.json.push(args).write()
return this.Read()
}
Defaults(args) {
const defaults = this.json.defaults(args).write()
this.json = defaults
return this.Read()
}
Delete(args) {
const deleted = this.json.remove(args).write()
return this.Read()
}
}
module.exports = DB