title: mongodb query to filter the array of objects using $gte and $lte operator
body: <p>My doucments:</p>
  <pre><code>[{
    &quot;_id&quot;:&quot;621c6e805961def3332bcf97&quot;,
    &quot;title&quot;:&quot;monk plus&quot;,
    &quot;brand&quot;:&quot;venture electronics&quot;,
    &quot;category&quot;:&quot;earphones&quot;,
    &quot;variant&quot;:[
        {
           &quot;price&quot;:1100,
           &quot;impedance&quot;:&quot;16ohm&quot;
        }, 
        {
          &quot;price&quot;:1600,
          &quot;impedance&quot;:&quot;64ohm&quot;
        }],
   &quot;salesCount&quot;:185,
   &quot;buysCount&quot;:182,
   &quot;viewsCount&quot;:250
  },
  {
   &quot;_id&quot;:&quot;621c6dab5961def3332bcf92&quot;,
   &quot;title&quot;:&quot;nokia1&quot;,
   &quot;brand&quot;:&quot;nokia&quot;,
   &quot;category&quot;:&quot;mobile phones&quot;,
   &quot;variant&quot;:[
        {
          &quot;price&quot;:10000,
          &quot;RAM&quot;:&quot;4GB&quot;,
          &quot;ROM&quot;:&quot;32GB&quot;
        },
        {
          &quot;price&quot;:15000,
          &quot;RAM&quot;:&quot;6GB&quot;,
          &quot;ROM&quot;:&quot;64GB&quot;
         }, 
        {
          &quot;price&quot;:20000,
          &quot;RAM&quot;:&quot;8GB&quot;,
          &quot;ROM&quot;:&quot;128GB&quot;
      }],
     &quot;salesCount&quot;:34,
     &quot;buysCount&quot;:21,
     &quot;viewsCount&quot;:80
  }]
  </code></pre>
  <p>expected output</p>
  <pre><code> [{
      _id:621c6e805961def3332bcf97
      title:&quot;monk plus&quot;
      brand:&quot;venture electronics&quot;
      category:&quot;earphones&quot;
      salesCount:185
      viewsCount:250
      variant:[
                {
                  price:1100
                  impedance:&quot;16ohm&quot;
                 }]
  }]
  </code></pre>
  <p>I have tried this aggregation method</p>
  <pre><code>[{
    $match: {
       'variant.price': {
        $gte: 0,$lte: 1100
        }
     }}, 
  {
    $project: {
          title: 1,
          brand: 1,
          category: 1,
          salesCount: 1,
          viewsCount: 1,
     variant: {
           $filter: {
               input: '$variant',
               as: 'variant',
               cond: {
                   $and: [
                      {
                        $gte: ['$$variant.price',0]
                      },
                      {
                        $lte: ['$$variant.price',1100]
                      }
                     ]
                  }
                }
              }
           }}]
  </code></pre>
  <p>This method returns the expected output, now my question is there any other better approach that return the expected output.Moreover thank you in advance, and as I am new to nosql database so I am curious to learn from the community.Take a note on expected output all properties of particular document must return only the variant array of object I want to filter based on the price.</p>