start with adapter

This commit is contained in:
Leifer Mendez
2022-01-15 13:23:56 +01:00
parent 1d3410ac91
commit ccca7f5612
8 changed files with 104 additions and 17 deletions

12
adapter/index.js Normal file
View 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
View 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}