Home > Blockchain >  squelize and sqlite concat two column and place conditional in where on that
squelize and sqlite concat two column and place conditional in where on that

Time:04-23

this.User.findAll({
  attributes: ['id', [sequelize.literal("firstname || 
        ' ' || lastname "),"
        fullName "],"
        fullName "],where:  {
          fullName: {
            [Op.like]: '%'   searchData   "%"
          }
        }
      })

//SQLITE_ERROR: no such column: fullName

CodePudding user response:

Use the same literal in Sequelize.where to achieve your goal:

this.User.findAll({
  attributes: ['id', [sequelize.literal("firstname || 
        ' ' || lastname "),"
        fullName "],"
        fullName "],
  where: Sequelize.where(sequelize.literal("firstname || 
        ' ' || lastname "), Op.like, '%'   searchData   '%')
      })
  • Related