Closed zapatista closed 12 years ago
Hi Zapatista,
Hmm, it might pay to read the documentation a bit more. First you're running find on documents where you should be running find on collections.
eg. Catalog_Class_Name::find(array('relatedItem.$.itemGuid' => 20));
That should return the document with a subdocument containing itemGuid value of 20. Remember you're querying from php, not js so we can't use native json. Queries are structured using php arrays so you do use '=>' to separate values. Apart from that the query language is exactly the same as standard mongo.
Cheers, Coen
i've tried that before Catalog_Class_Name::find(array('relatedItem.$.itemGuid' => 20)); no result; class Application_Model_Db_Table_Mongo_Catalog extends Shanty_Mongo_Document { protected static $_db = "holemp"; protected static $_collection = "catalog"; protected static $_documentSetClass = "Application_Modul_Db_Table_Mongo_Catalogs"; protected static $_requirements = array( 'relatedItem' => 'DocumentSet', 'relatedItem.$.itemGuid' => 'Required', ); } class Application_Modul_Db_Table_Mongo_Catalogs extends Shanty_Mongo_DocumentSet {}
thanks,
i've a data : "relatedItem" : { "0" : { "itemGuid" : "10" }, {"1" : {"itemGuid" : "20" }
I tried:
how to match an entire document within the relatedItem array ?
thanks, I appreciate the quick response