Skip to content

Instantly share code, notes, and snippets.

@alfredhot
Created May 11, 2018 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfredhot/1e26c7f98b565d59c8a5b4bcb1ce6f43 to your computer and use it in GitHub Desktop.
Save alfredhot/1e26c7f98b565d59c8a5b4bcb1ce6f43 to your computer and use it in GitHub Desktop.
db.influencers.aggregate([
{
$match: {ac: 1}
},
{
$project: {_id: 1}
},
{
$lookup: {
from: 'media',
let: {in_id: '$_id'},
pipeline: [
{
$match: {
$expr: {
$eq: ['$i_id', '$$in_id']
}
}
}
],
as: 'media'
}
},
{
$match: {media: {$ne: []}}
},
{
$unwind: '$media'
},
{
$limit: 20
}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment