I am learning Doctrine 2 ODM for MongoDB and have a straight forward question that i cant find an answer to in Doctrines docs or on google.
Say i have the following two documents in the same collection
{ "_id" : ObjectId("51c8a962f6d6ace76b374219"),
"X" : 26,
"Name" : "some name",
"Level" : "Common"
}
{
"_id" : ObjectId("51c8a9bef6d6ace76b37421a"),
"Y" : 1,
"Name" : "Other name",
"Level" : "Common"
}
I know i can find all documents that have Level : Common using
$dm->getRepository('Search\Model')->findBy(array("Level" => "Common"));
But how can i find all documents where field type is "X" and not "Y"? I know i could return all and filter it out but i should be able to query this right? Because the fields types X and Y are different should they be in a separate collection?
I've also tried various queries using query builder as in the Doctrine docs but no luck.
I really want to be able to return all documents in that collection that are only "X".
Many thanks