fix(cli): 🔥 update instructions

This commit is contained in:
Leifer Mendez
2022-12-18 14:14:16 +01:00
parent 96e220cd71
commit a21633fb7c
6 changed files with 16 additions and 24 deletions

View File

@@ -0,0 +1,47 @@
const StormDB = require('stormdb')
const { join } = require('path')
const engine = new StormDB.localFileEngine(join(process.cwd(), './db.stormdb'))
class JsonFileAdapter {
db
listHistory = []
constructor() {
this.init().then()
}
init() {
return new Promise((resolve) => {
this.db = new StormDB(engine)
this.db.default({ history: [] })
resolve(this.db)
})
}
getPrevByNumber = async (from) => {
const response = await this.db.get('history')
const { history } = response.state
if (!history.length) {
return null
}
const result = history.filter((res) => res.from === from).pop()
return {
...result,
}
}
save = async (ctx) => {
await this.db
.get('history')
.push({ ...ctx })
.save()
console.log('Guardado en DB...', ctx)
this.listHistory.push(ctx)
}
}
module.exports = JsonFileAdapter