title: case sensitive aggregation in mongodb using mongoose
body: <p>Hi all I am trying to do a auto populate dropdown search using mongoose and mongodb. I have written a aggregate query which works case insensitive was like if there are 2 datas like &quot;brand&quot; and &quot;Brand&quot; if i give &quot;brand&quot; it gives output for both &quot;brand&quot; and &quot;Brand&quot;. Below is my aggregate query</p>
  <pre><code>var aggregate = model.aggregate([
    {
      $match:{
       deleted: false
     }
    },
    {
      $group: {
        _id: $brand,
        Id: { $first: '$_id' },
        count: { $sum: 1 }
      }
    },
    {
      $project: {
        _id: '$Id',
        name: '$_id',
        count: '$count',
        insensitive: { $toLower: '$_id' }
      }
    },
    { $sort: { insensitive: 1 } },
    {
      $project: {
        _id: '$_id',
        name: '$name',
        count: '$count'
      }
    },
  
  ] );
  </code></pre>
  <p>My use case here is that i should display only the data specified like if i give brand it should display only &quot;brand&quot; and not &quot;Brand&quot;. Kindly help me</p>