coen-hyde / Shanty-Mongo

Shanty Mongo is a mongodb library for the Zend Framework. Its intention is to make working with mongodb documents as natural and as simple as possible. In particular allowing embedded documents to also have custom document classes.
Other
200 stars 52 forks source link

Get parent of subdocument #56

Open rremigius opened 12 years ago

rremigius commented 12 years ago

Hi,

I retrieve a Document (Parent) from the database and it contains a DocumentSet. I run through this DocumentSet and pass its elements (let's call them Subs) it on to other classes and methods. In some of these methods, I need the Parent document.

I found a method called isParentDocumentSet, but no method called anything like getParent. If I can't get the Parent directly from the Sub, I would have to pass the parent along with the Sub to all these methods, which I don't feel much for.

Is it possible to get the parent document directly from a sub-document? If not, might that be a good new feature?

Thanks.

coen-hyde commented 12 years ago

Hi Remix,

There is no getParent method at the moment but that can certainly be done.

Cheers, Coen

rremigius commented 12 years ago

Thanks. I added a 'parent' configAttribute and it works. Are you interested in these changes?

tholder commented 12 years ago

I've certainly had a need for this, it would be good to get these changes remix. Do you have a forked project?

rremigius commented 12 years ago

I made a fork. It's located here: https://github.com/remix88/Shanty-Mongo. Hope you find it useful.