Node.JS MongoDB Driver is used. The database entries look like that:
{
_id: ObjectId("224444202654a21928801814"),
category: "Test",
entries: [
{
_id: ObjectId("324444202dd4a21328802214"),
username: "Tester",
},
{
_id: ObjectId("324444232dd4a21328802215"),
username: "Tester2",
}
[many more...]
]
}
There are thousands of objects in the entries array. The last array entries are the newest ones. Now all objects should be deleted inside the entries array except the last 50 entries. Is there a possibility to achieve that with one update/remove call? Maybe with the $slice operator?