Skip to content

Instantly share code, notes, and snippets.

@npentrel
Created September 14, 2018 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npentrel/fdd45503934023166a60392494867f1d to your computer and use it in GitHub Desktop.
Save npentrel/fdd45503934023166a60392494867f1d to your computer and use it in GitHub Desktop.
> db.alphabet.insert({
"_id": "88888",
"array": ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
})
> db.alphabet.update(
{ "_id": "88888" },
{
$push: {
array: {
$each: ['a'],
$position: -999999999
}
}
}
)
// Check the results:
> db.alphabet.find({ "_id": "88888" })
{ "array" : [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" ] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment