UUID memory without relation UUID DB

This commit is contained in:
Leifer Mendez
2022-11-16 23:16:54 +01:00
parent ce8e7be9d7
commit 76968ded02
6 changed files with 39 additions and 11 deletions

View File

@@ -9,7 +9,6 @@ class MongoAdapter {
listHistory = []
constructor() {
console.log({ DB_URI })
this.init().then()
}
@@ -17,7 +16,7 @@ class MongoAdapter {
try {
const client = new MongoClient(DB_URI, {})
await client.connect()
console.log('Connected successfully to server')
console.log('🆗 Conexión Correcta DB')
const db = client.db(DB_NAME)
this.db = db
return true
@@ -27,6 +26,16 @@ class MongoAdapter {
}
}
getPrevByNumber = async (from) => {
const result = await this.db
.collection('history')
.find({ from })
.sort({ _id: -1 })
.limit(1)
.toArray()
return result[0]
}
save = async (ctx) => {
await this.db.collection('history').insert(ctx)
console.log('Guardando DB...', ctx)