1
return options.model.findOne({
      // $or: [{id: req.params.id}, {key: req.params.id}],
      where: {id: req.params.id},
    })

I am trying to get the $or to work properly, and for the most part it does. However, if I pass in a fake value (one that doesn't exist in my DB) the $or still returns a value, while the where does not.

I looked at http://docs.sequelizejs.com/en/latest/docs/querying/

Though it really doesn't offer to much help on the $or operator. Anybody experienced this and know a good work around?

Thomas Valadez
  • 1,697
  • 2
  • 22
  • 27

1 Answers1

0

Ok through some searching I was able to find this answer. Sequelize OR condition object

For me I found the syntax to be a bit confusing. Anyway you can nest the $or like this.

where: {
        $or: [
          {id: {$eq: req.params.id}},
          {key: {$eq: req.params.id}}
        ]
      }
Community
  • 1
  • 1
Thomas Valadez
  • 1,697
  • 2
  • 22
  • 27