title: Unrecognized expression '$toObjectId' in mongoose aggregation
body: <p>In my mongoose aggregation, I am getting error as <code>Unrecognized expression '$toObjectId'</code>. My MongoDB version is 4.2.5 and the mongoose version is 5.9.6. As per documentation, this operator is available in 4.x version and ideally should have worked. </p>
  
  <pre><code>  const trips = await Tickets.aggregate([
                {$match: {trip: Utils.strToObjectId(tripid) }},
                {$project: {_id:0,status:1, bookedBy:1,name:1,totalFare:1, seats:1, mode:1 }},
                {$group: {_id: {$toObjectId:"$bookedBy"}, bookings: {$push: {status: "$status", mode:"$mode", name: "$name", from: "$sourceCity", to: "$destinationCity", seats: "$seats" ,fare: "$totalFare", pnr: "$shortid" }}  }},
                {$lookup: {from:"users", localField:"bookedBy", foreignField:"_id",as:"user"}},
                ]);
  </code></pre>
  
  <p>In my case bookedBy get converted to string which is not matching in $lookup pipeline. so to resolve this I am trying to convert it to objectId.</p>
  
  <p>Any help suggestion is appreciated.</p>