node.js sequelize: multiple 'where' query conditions
Please note that as of this posting and the 2015 version of sequelize, the above answers are out of date. I am posting the solution that I got working in hopes of saving someone some time.
filters["State"] = {$and: [filters["State"], {$not: this.filterSBM()}] };
Note the $ and array inside the JSON object and lack of ? token replacement.
Or put in a more general way, since that might help someone wrap their head around it:
{ $and: [{"Key1": "Value1"}, {"Key2": "Value2"}] }
You can do:
Post.findAll({ where: {deletedAt: null, topicId: req.params.id} })
Which would be translated to deletedAt IS NULL
BTW, if you need deletedAt NOT IS NULL
, use:
Post.findAll({ where: {deletedAt: {$ne: null}, topicId: req.params.id} })
Just do:
Post.findAll(
{ where: ["topicId = ? AND deletedAt IS NULL", req.params.id] }
).success()
Or do you need an or query?