You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi i am relatively new to ODM concepts with doctrine. I found there is no documentation updated for '$filter' array aggrgation filters. I am having trouble in returning only the matched embedded document using MongoDB ODM query builder in PHP. Each embedded document has a MongoID generated at the time of creation. Following is my document structure of collection Project:
Now i want to retrieve from the database only the class from the classes embedded documents which meets my criteria (i.e. class with a specific id).This is how i am building the query with simple query builder:
First i match with the project id then i match with the embedded document class id. I was expecting it to return only the embedded document of OLA like this:
But doctrine is returning the whole Project record (shown in the start of question).I also tried with aggregation query building with the $match aggregation and $filter array operators of mongodb like this:
MongoResultException\nCode: 16410\nMessage: localhost:27017: FieldPath field names may not start with '$'.\nFile: /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/CommandCursor.php\nLine: 194\nTrace: #0 /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/CommandCursor.php(194): MongoCommandCursor->rewind()\n#1 /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/CommandCursor.php(257): Doctrine\\MongoDB\\CommandCursor->Doctrine\\MongoDB\\{closure}()\n#2 /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/CommandCursor.php(195): Doctrine\\MongoDB\\CommandCursor->retry(Object(Closure))\n#3 /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/CommandCursor.php(191): Doctrine\\MongoDB\\CommandCursor->rewind()\n#4 /var/www/html/doctor/api/index.php(559):
I also tried adding a question on stackoverflow but not got any reply so far. Can anyone help me because i think i am using the wrong syntax for creating aggregation query builder but i am unable to find any example how to make it right.
The text was updated successfully, but these errors were encountered:
Hi i am relatively new to ODM concepts with doctrine. I found there is no documentation updated for '$filter' array aggrgation filters. I am having trouble in returning only the matched embedded document using MongoDB ODM query builder in PHP. Each embedded document has a MongoID generated at the time of creation. Following is my document structure of collection Project:
Now i want to retrieve from the database only the class from the classes embedded documents which meets my criteria (i.e. class with a specific id).This is how i am building the query with simple query builder:
First i match with the project id then i match with the embedded document class id. I was expecting it to return only the embedded document of OLA like this:
But doctrine is returning the whole Project record (shown in the start of question).I also tried with aggregation query building with the $match aggregation and $filter array operators of mongodb like this:
But i am getting following exceptions:
MongoResultException\nCode: 16410\nMessage: localhost:27017: FieldPath field names may not start with '$'.\nFile: /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/CommandCursor.php\nLine: 194\nTrace: #0 /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/CommandCursor.php(194): MongoCommandCursor->rewind()\n#1 /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/CommandCursor.php(257): Doctrine\\MongoDB\\CommandCursor->Doctrine\\MongoDB\\{closure}()\n#2 /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/CommandCursor.php(195): Doctrine\\MongoDB\\CommandCursor->retry(Object(Closure))\n#3 /var/www/html/doctor/lib/composer/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/CommandCursor.php(191): Doctrine\\MongoDB\\CommandCursor->rewind()\n#4 /var/www/html/doctor/api/index.php(559):
I also tried adding a question on stackoverflow but not got any reply so far. Can anyone help me because i think i am using the wrong syntax for creating aggregation query builder but i am unable to find any example how to make it right.
The text was updated successfully, but these errors were encountered: