'mongodb fetching and filtering data -aggregate
I have two collections on mongodb one comments and other is tv shows. I want to fetch comments of chosen show on its detail page but I keep fetching every comment on collection in detail page -not filtered way basically-. I guess I have to use $lookup operator but I'm not so familiar with it.
TvShows.aggregate([{
$lookup: {
From: ‘Comments’,
LocalField: ‘_id’,
foreignField: ‘_id’,
as: ‘TvShow_comments’
}}]);
for example at this code how I can get the commented tv shows name or it's id to match it with LocalField in foreignField? I don't understand. Thank you for any help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
