Warning: This only supports READ operations.
A plugin to add support to li3 embedded relations for MongoDb. Lithiums mongo adapter says it supports embedded relations, but after much investigation through the core it appears this is not the case. Basically, when an embedded relation is specified, it does the single query for the parent and when the data is returned it creates the appropriate model with the data returned from the parent.
Secondly, the DocumentSet class which represents the array at each level of a Mongo document, has metadata attached. In applications with heavily branched documents, that metadata can add tens of MB of RAM overhead. This substitutes a simple Iterator/ArrayAccess wrapper for the array of data.
DocumentSet is still used for the main container set of documents.
libraries
directory.config/bootstrap/libraries.php
:Add the plugin in your config/bootstrap/libraries.php
file:
<?php
Libraries::add('li3_svelte_document');
?>
Next, in your app/config/connections.php specify this extended MongoDB adapter.
Connections::add('default', array(
'type' => 'MongoDb',
'adapter' => 'MongoSvelte',
'host' => 'localhost',
'database' => 'foo'
));
Continue defining relations in the lithium specified way as described here, except for the embedded key
class Team extends \lithium\data\Model.php {
public $hasMany = array(
'Players' => array(
'to' => 'Players',
'embedded' => 'players'
),
'Scouts' => array(
'to' => 'Scouts',
'embedded' => 'scouts',
),
);
Key specified is the name used to reference the relation on a find query.
Options are:
lithium\util\Collection
operations that DocumentSet does.