title: Sequelize, how to use Op.contains to find models that have certain values
body: <p>I'm working on some project about renting houses and appartments and I've reached the point when i need to implement filtering houses based on features they have(wifi, security and other staff). In the beginning I decided to try Sequelize ORM for the first time. Stuff like adding, creating, editing is working fine, but the filtering part is where I have some problems.</p>
  
  <p>I'm working with nodejs,express and postgresql. 
  I need to find all houses that have features listed in the array of features IDs. Here is what I've tried. In this example I'm trying to get houses which have features with ids 1, 2 and 4.</p>
  
  <pre><code>db.House.findAll({
    include: [{
      model: db.HouseFeature, 
      as: 'HouseFeatures',
      where: {
        featureId: {
          [Op.contains]: [1, 2, 4] //&lt;- array of featuresIds
        }  
      }
    }]
  })
  </code></pre>
  
  <p>Fetching houses by single feature id works fine because i don't use Op.contains there.
  Here are some relations related to this case:</p>
  
  <pre><code>House.hasMany(models.HouseFeature, { onDelete: 'CASCADE' });
  HouseFeature.belongsTo(models.House);
  </code></pre>
  
  <p>HouseFeature contains featureId field.
  Here is the error I get:</p>
  
  <pre><code>error: оператор не существует: integer @&gt; unknown
         at Connection.parseE (C:\***\server\node_modules\pg\lib\connection.js:601:11)
         at Connection.parseMessage (C:\***\server\node_modules\pg\lib\connection.js:398:19)
         at Socket.&lt;anonymous&gt; (C:\***\server\node_modules\pg\lib\connection.js:120:22)
         at Socket.emit (events.js:182:13)
         at addChunk (_stream_readable.js:283:12)
         at readableAddChunk (_stream_readable.js:264:11)
         at Socket.Readable.push (_stream_readable.js:219:10)
         at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
       name: 'error',
       length: 397,
       severity: 'ОШИБКА',
       code: '42883',
       detail: undefined,
       hint:
        'Оператор с данными именем и типами аргументов не найден. Возможно, вам следует добавить явные приведения типов.',
       position: '851',
       internalPosition: undefined,
       internalQuery: undefined,
       where: undefined,
       schema: undefined,
       table: undefined,
       column: undefined,
       dataType: undefined,
       constraint: undefined,
       file:
        'd:\\pginstaller.auto\\postgres.windows-x64\\src\\backend\\parser\\parse_oper.c',
       line: '731',
       routine: 'op_error',
       sql:
        'SELECT "House"."id", "House"."title", "House"."description", "House"."price", "House"."address", "House"."lat", "House"."lon", "House"."kitchen", "House"."bathrooms", "House"."floor", "House"."totalFloors", "House"."people", "House"."area", "House"."bedrooms", "House"."trusted", "House"."createdAt", "House"."updatedAt", "House"."CityId", "House"."ComplexId", "House"."OwnerProfileId", "House"."HouseTypeId", "House"."RentTypeId", "HouseFeatures"."id" AS "HouseFeatures.id", "HouseFeatures"."featureId" AS "HouseFeatures.featureId", "HouseFeatures"."createdAt" AS "HouseFeatures.createdAt", "HouseFeatures"."updatedAt" AS "HouseFeatures.updatedAt", "HouseFeatures"."HouseId" AS "HouseFeatures.HouseId" FROM "Houses" AS "House" INNER JOIN "HouseFeatures" AS "HouseFeatures" ON "House"."id" = "HouseFeatures"."HouseId" AND "HouseFeatures"."featureId" @&gt; \'1,2\';'
  </code></pre>
  
  <p>Sorry for some russian there.</p>
  
  <p>UPDATE:</p>
  
  <p>I've managed to do what i needed by changing each House relating only to one HouseFeature, and by changing that HouseFeature model to store array of featureIds. Op.contains works fine.</p>
  
  <pre><code>  db.House.findAll({
        include: [{
          model: db.HouseFeature, 
          as: 'HouseFeature',
          where: {
            features: {
              [Op.contains]: req.body.features
            }  
          },
        }]     
    })
    // Associations
    HouseFeature.belongsTo(models.House);
    House.hasOne(models.HouseFeature, { onDelete: 'CASCADE' });
  
    const HouseFeature = sequelize.define('HouseFeature', {
      features: {
        type: DataTypes.ARRAY(DataTypes.INTEGER)
      }
    }, {});
  
  </code></pre>
  
  <p>Now i have one little issue. Can I somehow link HouseFeature model with Feature model to fetch feature icon images and name later on? With Feature ids being stored inside HouseFeature array.</p>