Lets say we have a document in MongoDB contains an array ob objects like this:
addresses: [
{
city: "Tel Aviv",
street: "Alenby",
streetNumber: 50
},
{
city: "Jerusalem",
street: "King David",
streetNumber: 10
},
{
city: "Beer Sheva",
street: "King Shlomo",
streetNumber: 20
}
]
THE QUESTION SLICED FOR SINGLE UNDER PIECES
We want to update the second address of this client, from King David 10 to King Shaul 35. How can we do that?
We want to remove only the second address by index or key or matched key+value.
We want to push another address between first to second, so first will remain first, a new address will be injected, and all of the next will be auto indexed by next.
Note: I am asking how do I do that using MongoDB query language, aka NoSQL. If you also have a solution for doing it using AngularJS it will be welcome, but please place it after the first solution for Mongo query language (MQL).
Thanks!