Searching on an other-table based Smart Field

Sorry it doesn’t. It crashes again :
Unexpected error: column identity.lastName does not exist

It needs to be the name in your database. in my case my column is name lastName but in your case it might be last_name ?

it indeed is last_name, lastName being the FA alias

it works indeed ! Thanks @vince

I changed it a bit a follows

const split = search.split(' ');
      const searchCondition = {
        [Op.or]: [
          { '$identity.last_name$': { [Op.iLike]: `%${split[0]}%` } },
          { '$identity.last_name$': { [Op.iLike]: `%${split[1]}%` } },
          { '$identity.first_name$': { [Op.iLike]: `%${split[0]}%` } },
          { '$identity.first_name$': { [Op.iLike]: `%${split[1]}%` } },
        ],
      };

      query.where[Op.and][0][Op.or].push(searchCondition);

      if (!query.include.find((include) => include.as === 'identity')) {
        query.include.push({
          model: models.identities,
          as: 'identity',
        });
      }
      return query;
1 Like