mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-19 20:19:15 +00:00
UUID memory without relation UUID DB
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user