0
我有一个Playlist
文件,它引用了许多Song
文件,这反过来又引用他人的文档:如何避免在创建新文档时加载参考文档?
/** @Document(collection="playlists") */
class Playlist
{
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ReferenceMany(targetDocument="Song", simple=true)
*/
protected $songs;
}
/** @Document(collection="songs") */
class Song
{
/**
* @var string
*
* @ReferenceOne(targetDocument="Foo", simple=true)
*/
protected $foo;
/**
* @var string
*
* @ReferenceOne(targetDocument="Bar", simple=true)
*/
protected $bar;
}
另一份文件Like
引用一个Playlist
:
/** @Document(collection="likes") */
class Like
{
/**
* @var Playlist
*
* @ReferenceOne(targetDocument="Playlist", simple=true)
*/
protected $playlist;
}
每次我坚持(插入)新Like
文档中,加载了一些引用(很深或很深)(执行了很多相关的查询);在这种情况下,这是无用的。
如何避免这种“贪婪”行为(模型重构,配置,缓存等)?