const { db } = require('./Database')

const setStatus = (device, status) => {
    try {
        db.query(`UPDATE numbers SET status = '${status}' WHERE body = ${device} `)
        return true;
    } catch (error) {
        return false
    }
}

function dbQuery(query) {
    return new Promise(data => {
        db.query(query, (err, res) => {
            if (err) throw err;
            try {
                data(res);
            } catch (error) {
                data({});
                //throw error;
            }
        })
    })
}



module.exports = { setStatus, dbQuery }