I have a mongoDB application running on symfony2.2 framework.
The Database design is as follows.
Table
User,City,State
1 user belongs to one city.
1 city belongs to one state.
now I need to query all the users who belong to state A.
This is what i tried but with no result.
$response = $dm->getRepository('DataBundle:User')->createQueryBuilder()
->field('city.state.$id')->equals(new \MongoId('123123asd123dqa4'))
->getQuery()
->execute();
Any Ideas?
[EDIT]
class User
{
/**
* @ODM\ReferenceOne(targetDocument="City", mappedBy="users")
*/
protected $city;
// getters and setters
}
class City
{
/**
* @ODM\ReferenceOne(targetDocument="State")
*/
protected $state;
/**
* @ODM\ReferenceMany(targetDocument="User", inversedBy="state")
*/
protected $users;
//getters and setters
}