Sequelize OR condition object

后端 未结 6 1734
-上瘾入骨i
-上瘾入骨i 2020-12-08 03:38

By creating object like this

var condition=
{
  where:
  {
     LastName:\"Doe\",
     FirstName:[\"John\",\"Jane\"],
     Age:{
       gt:18
     }
  }    
         


        
6条回答
  •  既然无缘
    2020-12-08 04:14

    String based operators will be deprecated in the future (You've probably seen the warning in console).

    Getting this to work with symbolic operators was quite confusing for me, and I've updated the docs with two examples.

    Post.findAll({
      where: {
        [Op.or]: [{authorId: 12}, {authorId: 13}]
      }
    });
    // SELECT * FROM post WHERE authorId = 12 OR authorId = 13;
    
    Post.findAll({
      where: {
        authorId: {
          [Op.or]: [12, 13]
        }
      }
    });
    // SELECT * FROM post WHERE authorId = 12 OR authorId = 13;
    

提交回复
热议问题