4. Basic Usage
4.3. Embedded Documents
4.2. Simple Embeded Document Model
« Previous
4.4. Arrays
Next »

4.3. Embedded Documents

AuthorDariusz Górecki

Basic informations about embedded documents

Must know:

Defining embedded documents within document

This applies to EMongoDocument and EMongoEmbeddedDocument

Just define the embeddedDocuments() method in yours model class, it should return array of simple key => value pairs.

example:

// ...
// within model class
public function embeddedDocuments()
{
    return array(
        'address' => 'UserAddress',
        'some_other_field_name' => 'AnyEMongoEmbeddedDocumentChildClass',
    );
}
 
// this will give you access to propeties of model:
$model->address->embeddedExampleField;
$model->some_other_field_name->embeddedExampleField;

How to force save of embedded document into collection

4.3. Embedded Documents
4. Basic Usage
« Previous
4.2. Simple Embeded Document Model
Next »
4.4. Arrays