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);