человек, у меня проблема.В рамках этой модели я делаю свой sql-запрос:
module.exports.contribId = (request, callback) => {
connection.query(
'SELECT * FROM planilla_produccion_cantera WHERE id_planilla_produccion_cantera = ?',
request,
(err, result) => {
var objPlanilla = {
id: result[0].id_planilla_produccion_cantera,
periodo: result[0].periodo
};
console.log('MY OBJ EN DAO: ', objPlanilla);
callback(null, objPlanilla);
}
);
Затем в моем контроллере я хочу выполнить циклический переход по карте, чтобы получить число раз, когда мой массив, и сделать запрос на выбор для моей модели числавремен массива:
module.exports.contribId = (запрос, обратный вызов) => {const todo = [];
const mapAsync = (arr, fn) => Promise.all(arr.map(fn));
mapAsync(request, id =>
contribModel.contribId(id, function(err, docs) {
todo.push(docs); //here I need to push each value
})
);
console.log(todo); //here I need to print all the values of mapsync
}
но яне может получить массив уже завершен.Не могли бы вы помочь мне?