I have a model which requires a date input in the where clause for a query.
const Model = sequelizeTwo.define('model', {
A: Sequelize.BIGINT,
B: Sequelize.DOUBLE,
C: Sequelize.DOUBLE,
D: Sequelize.DOUBLE,
E: Sequelize.DOUBLE,
F: Sequelize.DOUBLE,
DATE: Sequelize.DATEONLY,
newCol: Sequelize.VIRTUAL
},{
tableName: "Model",
timestamps: false,
freezeTableName: true
})
DATE
here is used as a params for the query to display information on the client. But that is the end of it's use. I don't want to send DATE
to the client back but I see no way to remove it.
If i remove it from the model, it gives a timezone error which is another problem as well.
app.get('/api/:date', (req, res) => {
var date = req.params.date
Model.findAll({
where: {
DATE: {
[Op.eq]: date
}
},
order: [
['A', 'ASC']
]
}).then(result => {
...
for (i; i < result.length; i++) {
...
delete result[i].DATE
console.log(result[i].DATE)
result[i]["newCol"] = values;
}
res.json(result);
})
})
I have tried using the delete operator inside and outside the loop, but it's of no use. It still retains the property and sends it back to the client
delete result[i].DATE //Inside loop
delete result.DATE //before loop
The values do they get updated when assignment is done but the property/key can't be modified.
result[i].DATE = null or undefined
What i want to achieve here is that I just want to send an object back which has all the properties in the sequelize model except DATE