I'm using Sequelize with sqlite3 but having trouble querying data based on "date" type columns.
Here is my model definition:
var sensorData = sequelize.define('Data', 
{
    time: Sequelize.DATE,
    value: Sequelize.FLOAT,
    type: Sequelize.STRING,
    source: Sequelize.STRING
},
{
    timestamps : false
});
Now I want to get all the records with 'time' later than a given time in this function:
function selectData(start_date, num_of_records, callback)
{
    sensorData.findAll({
        limit: num_of_records, 
        where: [time, '???'], <====== How to specify the condition here?
        order: 'time'}).success(callback);
}
I can't find any thing on Sequelize's website about 'date' type based query statement.
Any idea?
Just like Soumya says, you can use $gt, $lt, $gte or $lte with a date:
model.findAll({
  where: {
    start_datetime: {
      $gte: new Date()
    }
  }
})
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With