Operators in Sequelize Usage with where

时间:2017-08-04 12:35:48

标签: javascript sequelize.js

I am trying to get the data from the datebase with in a range of time. we are using

let contactWhere = {};

if (filter.username) {
    contactWhere.username = filter.username;
}
    dbSequelize.Mytable.findAll({
    where: {
            application_id: filter.application_id
        },
        include: [
        {
            model: dbSequelize.NeuronContact, 
            as: 'contact',
            where: contactWhere,
            required: true
        }
    ] })

I am trying filter the date which column "time" is string.

`

dbSequelize.Mytable.findAll({
        where: {
                time:            {
                 $gte : moment(msg.msgData.startDate, "DD/MM/YYYY"),
                 $lte: moment(msg.msgData.startDate, "DD/MM/YYYY")
            },
                application_id: filter.application_id
            }})

`

Do I have to change the column to timestamp? or can I do this bigger smaller process on string? If I can do. How can I ? I was trying to help from here but ı coudnt. http://docs.sequelizejs.com/manual/tutorial/querying.html

0 个答案:

没有答案