Given the DB is in the state at the end of the post: http://jwage.com/post/30490176882/multiple-levels-of-embedded-documents-in-mongodb and we have, in Mongo the structure of
Array
(
[_id] => MongoId Object
(
)
[username] => jwage
[profiles] => Array
(
[0] => Array
(
[name] => Profile #1
[addresses] => Array
(
[0] => Array
(
[number] => 6512
[street] => Mercomatic
[city] => Nashville
[state] => Tennessee
[zipcode] => 37209
)
)
)
[1] => Array
(
[name] => Profile #2
[addresses] => Array
(
[0] => Array
(
[number] => 475
[street] => Buckhead Ave
[city] => Atlanta
[state] => Georgia
[zipcode] => 30303
)
)
)
)
)
How do you go about adding a new Address to one Profile of many of a specific User?
Create the new Address.
$newAddress = new Address();
$newAddress->setCity('Albany'); // etc
Attach to the profile within the 'top level' User document.