answear: function(id){
return new Promise((resolve, reject) => {
db.query(
'SELECT * FROM answers WHERE id_question IN ( ? )',
[id],
(err, rows) => {
if(err) reject(err);
console.log(rows);
resolve(rows);
});
}).then(rows => {return rows;});
{
answear(ids) {
return new Promise((resolve, reject) => {
const bindings = ids.map(id => '?').join(',');
db.query(
`SELECT * FROM answers WHERE id_question IN (${bindings})`,
ids,
(error, rows) => {
if (error) {
return reject(error);
}
resolve(rows);
}
);
});
}
}