How to $lookup Component documents in custom $aggregate query?

I have collection type Place which have field links which use component Link which have fields like url and title. Place has also field named cover which is Media field. Getting value for cover works fine but links does not.

Place document in MongoDB (relevant fields)

   {
    _id: ObjectId('5fdb7c87fa0aaf11d6ef4788'),
    cover: ObjectId('5fc94314f0bf8afd27d5badc'),
    links: [
        {
            _id: ObjectId('60116c3e3f589afbed80256f'),
            kind: 'ComponentLinkLink',
            ref: ObjectId('6011631faaace7f5dbcf24b8')
        }
    ],
    geometry: {
        type: 'Point',
        coordinates: [
            61.4903,
            21.7997
        ]
    },
  }

Custom query to get places by location

 entities = await strapi
        .query("place")
        .model.aggregate([
          {
            $geoNear: {
              near: {
                type: "Point",
                coordinates: [latitude, longitude],
              },
              distanceField: "dist.calculated",
              maxDistance: distance,
              spherical: true,
            },
          },
          {
            $lookup: {
              from: "upload_file",
              localField: "cover",
              foreignField: "_id",
              as: "cover",
            },
          },
          {
            $unwind: "$cover",
          },
          {
            $lookup: {
              from: "link",
              localField: "links['$ref']",
              foreignField: "_id",
              as: "links",
            },
          },
          {
            $unwind: "$links",
          },
          {
            $limit: limit,
          },
        ])
        .exec();

Working solution

  entities = await strapi
    .query("place")
    .model.aggregate([
      {
        $geoNear: {
          near: {
            type: "Point",
            coordinates: [latitude, longitude],
          },
          distanceField: "dist.calculated",
          maxDistance: distance,
          spherical: true,
        },
      },
      {
        $lookup: {
          from: "upload_file",
          localField: "cover",
          foreignField: "_id",
          as: "cover",
        },
      },
      {
        $unwind: "$cover",
      },
      {
        $unwind: "$links",
      },
      {
        $lookup: {
          from: "link",
          localField: "links.ref",
          foreignField: "_id",
          as: "links",
        },
      },
      {
        $limit: limit,
      },
    ])
    .exec();

Mongo Shell Query

db.places.aggregate([
          {
            $geoNear: {
              near: {
                type: "Point",
                coordinates: [61.4903, 21.7997],
              },
              distanceField: "dist.calculated",
              maxDistance: 300,
              spherical: true,
            },
          },
          {
            $lookup: {
              from: "upload_file",
              localField: "cover",
              foreignField: "_id",
              as: "cover",
            },
          },
           {
            $unwind: "$cover",
          },
          {
            $unwind: "$links",
          },
          {
            $lookup: {
              from: "link",
              localField: "links.ref",
              foreignField: "_id",
              as: "links",
            },
          },
         ])