Answer the question
In order to leave comments, you need to log in
How to output to the console after the end of the for processing?
now the console outputs before the script is executed, how to output to the console after the handicap?
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);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question