Skip to content

Instantly share code, notes, and snippets.

@npentrel
Created September 14, 2018 00:09
Show Gist options
  • Save npentrel/6d2ca6bd362f9d20e89a7349a6f615a4 to your computer and use it in GitHub Desktop.
Save npentrel/6d2ca6bd362f9d20e89a7349a6f615a4 to your computer and use it in GitHub Desktop.
> db.game.insert({
"_id": "55555",
"scores": [223, 220, 190, 176, 151, 139, 124, 123, 80, 57]
})
> db.game.update(
{ "_id": "55555" },
{
$push: {
scores: {
$each: [72],
$sort: -1,
$slice: 10,
}
}
}
)
> db.game.find({ "_id": "55555" })
{ "scores" : [223, 220, 190, 176, 151, 139, 124, 123, 80, 72] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment