doctrine/mongodb-odm — Issue #198: Allow Reference(One|Many) without using DBRefs
Author: AD7six
Created: 2011-11-24 15:04:44+00:00
State: open

I've seen some tickets that come close to this point:

https://github.com/doctrine/mongodb-odm/pull/136
https://github.com/doctrine/mongodb-odm/issues/142

But, in a nutshell it is not always desirable to use db refs. Infact, unless the target document can be any type - I would say it is detrimental to the db to do so.

For example:

/**
* @MongoDB\ReferenceOne(targetDocument="User")
*/
protected $createdBy;

storing `{$ref" :"users", id}` instead of `id` adds a few characters to each row in the collection - that can really add up for a collection with lots of rows.

Another example:

/**
* @MongoDB\ReferenceMany(targetDocument="User")
*/
protected $friends;

storing `[{$ref" :"users", id}, ...]` instead of `[id, ...]` turns an array into a huge amount of (duplicate) data.

I took a look in the code to see about proposing a patch, but I'm not familiar enough with the code to do that at this time.

Is this a known issue; is it infact already possible and I just haven't found how; or am I alone in not wanting the database to be a none-trivial % fatter than it needs to be?