title: getting problem with condition in mongodb
body: <p>See my condition does work fine for my history's first collection but for second it does not work either If I replace my specified id with <code>5e4a8d2d3952132a08ae5724</code> that exists in my second object of history's collection return me all data which is not correct because it's date is greater then main collection's date so it should return me nothing please suggest how to fix it. </p>
  
  <pre><code>db.main.aggregate([
    {
      $lookup: {
        from: "history",
        localField: "history_id",
        foreignField: "history_id",
        as: "History"
      }
    },
    {
      $unwind: "$History"
    },
    {
      "$match": {
        $expr: {
          $cond: {
            if: {
              $eq: [
                "5e4a8d2d3952132a08ae5764",
                "$History.user_id"
              ]
            },
            then: {
              $and: [
                {
                  $gt: [
                    "$date",
                    "$History.date"
                  ]
                },
                {
                  $eq: [
                    "5e4a8d2d3952132a08ae5764",
                    "$History.user_id"
                  ]
                }
              ]
            },
            else: {}
          }
        }
      }
    }
  ])
  </code></pre>
  
  <p>when I put two object into history collection it does not work either <a href="https://mongoplayground.net/p/mf4C8ccNcSc" rel="nofollow noreferrer">MongoPlayground</a></p>
  
  <p>Here is working playground with single history object <a href="https://mongoplayground.net/p/hrNofrq1c3S" rel="nofollow noreferrer">https://mongoplayground.net/p/hrNofrq1c3S</a></p>