Doctrine ODM query for $lookup with let/pipeline
azamalvi opened this issue · 1 comments
azamalvi commented
I have a query that is working fine in mongo shell but I want to convert that query into ODM style but I did not find the conditional statement syntex. Below is my query
db.getCollection('Source').aggregate([{
$lookup: {
from: 'translated',
localField: 'id',
foreignField: 'sourceId',
pipeline: [
{
$match: {
tl: 'en'
}
}
],
as: 'result'
}
}, {}]
and I tried this but unable to add the piplelne
$this->createAggregationBuilder(Source::class)
->lookup(Translated::class)
->localField('id')
->foreignField('sourceId')
// pipele should be here
->alias('result')
->getAggregation()->getIterator()->toArray();
What will be the right syntax/code to add pipleline/let with $lookup.
Second question is that is there any way that we can run first Query directly without ODM style.
malarzm commented
The feature is missing but will be provided by doctrine/mongodb-odm#2459