Reputation: 2303
I have a MongoDb Document, quiz...
/**
* @MongoDB\Document(
* collection = "Quizzes",
* repositoryClass = "Company\MyBundle\Repository\QuizRepository",
* slaveOkay = true
* )
*/
class Quiz extends QuizEntity
The quiz contains many questions
/**
* @MongoDB\EmbedMany(targetDocument="QuizQuestion", name="questions")
*/
protected $questions = array();
If i have the main ID of a question, how can i query the repository of the Quiz for it?
(meaning, find a quiz contains my question with the id=4333)
Upvotes: 2
Views: 145
Reputation: 30975
I'll use something like
/* $question = your question */
$dql = 'SELECT z FROM YourBundle:Quiz z INNER JOIN z.questions q WITH q= :question';
$yourQuery->setParameter('question', $question);
Upvotes: 1