1
votes

So i don't know the type of an document I want retrieve and thus have no idea how to retrieve this document in a doctrine manner. Normally i would do somethink like that:

$dm->find('User', 12345);

And i should get the User class. But what if I don't know the type of the document? It's stored in document so Doctrine should figure it out. I should simple call

$dm->find(12345); //of course this doesn't work

and Doctrine should look into "type" field in the document and return the User class.

Of course i can do it by hand but maybe there is an Doctrine method for this problem?

So my question is: How to retrieve (using doctrine) the document and instantiate correct class (depending on the "type" field found in the document)?

1

1 Answers

1
votes

I think normally you would want to develop a view for each logical type of data that you want to look at, wherever it is in the document graph.

Otherwise you could write a view that looks at every document, looping through every property recursively, and find the value 12345, but that of course would, probably, be very slow.

The views can look at your type property (which is duck typing) and emit() the correct object.