1

I'm trying to get the last data inserted in my collection using MongoDB. This is my code:

dht11.aggregate(
  [ 
    {
        $lookup:
        {
          from: "storage_rooms",
          localField: "node",
          foreignField: "name",
          as: "MainStorage"
        }
    },
      { $unwind: "$MainStorage"},
      { $match: {node: "Main Storage"} },
  
 
  ]
  ).sort({$natural:-1}).limit(1);
  • 1
    Does this answer your question? [$skip and $limit in aggregation framework](https://stackoverflow.com/questions/24160037/skip-and-limit-in-aggregation-framework) – Charchit Kapoor Aug 08 '22 at 07:30

0 Answers0