a-musing-moose/morph — Issue #27: Querying Relationships
Author: russellseymour
Created: 2012-01-19 14:05:29+00:00
State: open

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.

Regards,

Russell