-2
I am creating an API in Nodejs using Sequelize to facilitate the manipulation of data from a Mysql database. I have a list of appointments and I need to count how many appointments a patient has from today’s date.
I saw in the documentation that using [Op.gte]
i can filter an age or things involving whole numbers. But I tried to use with Moment.js and the function Date
and it didn’t work.
I tried the following, without success:
const pacienteConsultas = await sequelize.models.consulta.count({
where: {
paciente_id: paciente_id,
data_hora: [Op.gte]: Date.now()
}
});
How can I do?
I made the modification to
data_hora: { [Op.gte]: Date.now() }
but still the error continued. But I found the error. The[Op.gte]
seems to be obsolete. I modified it todata_hora: { $gte: Date.now() }
and it worked. Thanks for your help.– Bob Nunes
@Bobnunes The object
Op
is not obsolete, you can check on official documentation of the latest version. Maybe you are importing wrong.– Rafael Tavares
I found this information on documentation. In v4 it still worked. But for V6 I am using, no.
– Bob Nunes