doctrine/couchdb-odm — pull request #71 by marnusw (2013-07-25 14:08:54+00:00)
Title: Suggest allowing @Index on @ReferenceOne fields

Since a `@ReferenceOne` field stores the ID of the referenced document it can be a useful field to have indexed with `@Index` thus making queries via `DocumentRepository::findBy()` available.

In my use case I have multiple invoices each with a reference to a user account, so this will allow me to find invoices for a given account. I realize I could obtain the same result with an inverse many-to-one mapping, but then I would have to retrieve the entire dataset, I can't use limit/offset (as far as I know). E.g. to show the most recent invoices for an account I can now retrieve only the relevant documents using the existing _doctrine_repositories_ view together with `setDescending(true)` and `setLimit(5)`.

Support for this combination of annotations has been added to the Annotation, XML and YAML mapping drivers, and `ClassMetadata::mapManyToOne()` also updates the indexes.