mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-19 12:09:15 +00:00
start with adapter
This commit is contained in:
12
adapter/index.js
Normal file
12
adapter/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const {getData} = require('./mysql')
|
||||
|
||||
const get = (step) => new Promise((resolve, reject) => {
|
||||
if(process.env.DATABASE === 'mysql'){
|
||||
getData(step,(dt) => {
|
||||
console.log('--->datos--',dt)
|
||||
resolve(dt)
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = {get}
|
||||
9
adapter/mysql.js
Normal file
9
adapter/mysql.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const {connection} = require('../config/mysql')
|
||||
|
||||
const getData = (option_key = '', callback) => connection.query(`SELECT * FROM db_test.keywords WHERE option_key = '${option_key}' LIMIT 1`,(error, results, fields) => {
|
||||
const [response] = results
|
||||
let parseResponse = response?.value || '';
|
||||
parseResponse = parseResponse.split(',') || []
|
||||
callback(parseResponse)
|
||||
});
|
||||
module.exports = {getData}
|
||||
Reference in New Issue
Block a user