Hi there! How to embed a document to another document?
Here is the example from the mongodb official documentation:
{
_id: "joe",
name: "Joe Bookreader",
address: {
street: "123 Fake Street",
city: "Faketon",
state: "MA",
zip: "12345"
}
}
For this user I need to create a model like this:
class User extends \Phalcon\Mvc\Collection {
public $id;
public $name;
}
Ok, and what about an object with an adress? Is it an additional object extended from \Phalcon\Mvc\Collection
?
What if it an array of objects like this:
{
_id: "joe",
name: "Joe Bookreader",
addresses: [
{
street: "123 Fake Street",
city: "Faketon",
state: "MA",
zip: "12345"
},
{
street: "1 Some Other Street",
city: "Boston",
state: "MA",
zip: "12345"
}
]
}
So, give me an example, please.