title: How to use $ilike in combination with $contains on array of objects in sequelize?
body: <p>I have two columns in postgres with JSONB datatype viz. 'category' and 'subcategory'. I need to make search on these columns on the basis of input from user. JSON in 'category' column looks like:</p>
  
  <pre><code>[{id: 36, name: "categoryName1"},{id: 42, name: "categoryName2"}]
  </code></pre>
  
  <p>and JSON in 'subcategory' column looks like: </p>
  
  <pre><code>[{id: 52, name: "subCategoryName1"},{id: 56, name: "subCategoryName2"}, {id: 70, name: "subCategoryName1"}]
  </code></pre>
  
  <p>Input can be 'id' or it can be a 'name'.The Query I have written as far tries to find exact same name in both the columns as per provided input. But I want to allow user to find even by partial name so trying to use <code>$ilike</code> operator. Query is as follow:</p>
  
  <pre><code>Model.findAll({
          where: {
            $or: {
              category: {
                $contains: [{
                  "name": {
                    $ilike: '%' + term + '%'
                  }
                }]
              },
              subcategory: {
                $contains: [{
                  "name": {
                    '$ilike': '%' + term + '%'
                  }
                }]
              }
            }
          }
        })
  </code></pre>
  
  <p>RAW QUERY:</p>
  
  <pre><code>SELECT "category", "subcategory" FROM "table" AS "table" 
  WHERE "table"."category" @&gt; '[{"name":{"$ilike":"%subCategoryName2%"}}]' 
  OR "table"."subcategory" @&gt; '[{"name":{"$ilike":"%subCategoryName2%"}}]'
  </code></pre>