Skip to content

Instantly share code, notes, and snippets.

@npentrel
Created September 13, 2018 23:47
Show Gist options
  • Save npentrel/5e1f1cec435843b090633c3787c0969b to your computer and use it in GitHub Desktop.
Save npentrel/5e1f1cec435843b090633c3787c0969b to your computer and use it in GitHub Desktop.
> db.alphabet.insert({
"_id": "00000",
"array": ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
})
// We missed the 'i'!
// Let's add it in the position before the last element.
> db.alphabet.update(
{ "_id": "00000" },
{
$push: {
array: 'i'
}
}
)
// Check the results:
> db.alphabet.find({ "_id": "00000" })
{ array : [ "a", "b", "c", "d", "e", "f", "g", "h", "i" ] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment