сейчас консоль выводит до выполнения скрипта, как сделать вывод в консоль после фора?
for(var i = 1; i <= pndLength; i++){
var directory = sequelize.define('pnd_' + i,{ // Модель запроса в БД отделения
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
allowNull: false
},
branch: {
type: Sequelize.INTEGER,
allowNull: false
},
subBranch: {
type: Sequelize.INTEGER,
allowNull: false
},
rank: {
type: Sequelize.STRING,
allowNull: false
},
addres: {
type: Sequelize.STRING,
allowNull: false
},
floor: {
type: Sequelize.STRING,
allowNull: false
},
cabinet: {
type: Sequelize.STRING,
allowNull: false
},
cphone: {
type: Sequelize.STRING,
allowNull: false
},
phone: {
type: Sequelize.STRING,
allowNull: false
},
name: {
type: Sequelize.STRING,
allowNull: false
}
});
directory.findAll({where:{
[Op.or]: [
{
name: {
[Op.substring]: `${request.body.text}`
}
},
{
rank: {
[Op.substring]: `${request.body.text}`
}
},
{
branch: {
[Op.substring]: `${request.body.text}`
}
},
{
subBranch: {
[Op.substring]: `${request.body.text}`
}
},
{
phone: {
[Op.substring]: `${request.body.text}`
}
}
]
}})
.then(otd =>{
var filter = 0;
for(o of otd){
result.push(o);
}
filter = result.reduce((acc, n) => {
const g = n.subBranch || n.branch;
(acc[g] = acc[g] || []).push(n);
return acc;
}, {});
})
}
console.log(result);