What is the mongoDB query for that mysql query how use join in mongoDB there is the problem i am facing to write in mysql?
SELECT t.uid, count(j.job_id) AS x
FROM verify AS t
LEFT JOIN jobs AS j
ON t.uid = j.job_id
What is the mongoDB query for that mysql query how use join in mongoDB there is the problem i am facing to write in mysql?
SELECT t.uid, count(j.job_id) AS x
FROM verify AS t
LEFT JOIN jobs AS j
ON t.uid = j.job_id
This would be like below by using aggregation framework with $project
& $lookup
pipeline :
db.collection1.aggregation[{
$project: {
'uid': 1,
"x": {
"$size": "job_id"
}
},
$lookup: {
from: 'collection2',
localField: 'uid',
foreignField: 'job_id',
as: 'j'
}
}]