Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Querying Relationships #27

russellseymour opened this Issue · 1 comment

3 participants


Hello again,

I have created a 'HasOne' relationship in a document with one in another collection.

Is it possible to query the document based on this relationship? For example, I have the relationship field set as 'moduleid' and I want to query all documents that have a specific Id and an 'adminnav' value of 1. My query at the moment is thus:

```$query = new \morph\Query();
$query ->property("moduleid")
-> equals(id)
-> property("adminnav")
-> equals(1)

I have tried to use the Id as a string and as a MongoId but neither of them have worked so I am beginning to think that it is down to the way I am trying to use the relationship.

Am I barking up the wrong tree or is this possible?  If it is possible please could you point me in the right direction?

Thanks for all your help.  I am thinking of forking this so I can add the 'or' method and some other ideas I have had.



I found the answer on the mongo website
db.postings.find( { "" : "joe" } );

You need to append the properties, in your case: moduleid.adminnav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.