Am a beginner in mongoDB. I have two collections Book and author. [name and workswritten] are the common column respectively. Using inner join I have to emit the some columns in
You can compare below codes for SQL and mongoDB (NoSQL):
SQL Code:
SELECT *, [output array field]
FROM collection
WHERE [output array field] IN (SELECT *
FROM [collection to join]
WHERE [foreignField]= [collection.localField]);
mongoDB (NoSQL):
{
$lookup:
{
from: [collection to join],
localField: [field from the input documents],
foreignField: [field from the documents of the "from" collection],
as: [output array field]
}
}