I just want to update the top 2 highest fields in the database.
db.Employee.update({
db.Employee.find().sort({
Age: -1
}).limit(2) --This part here wont work--
},
{
$set: {
Benefits: ["Vacation", "Rolex"]
}
}
)
Apparently MongoDB does not support such ability. How can I dynamically update the top 2 highest fields of my DB?
I do not want to resort to find the _id of the collection manually and then update the collection separately.