Answer the question
In order to leave comments, you need to log in
How to pass data from one $lookup to another?
There is an aggregate request that includes two $lookups:
[{
$match: {
id
}
},
{
$lookup: { // 1
from: 'blogs',
as: 'blog',
pipeline: [{
$project: {
id: 1, // * Отсюда
name: 1,
articles: 1
},
}, {
$match: {
articles: {
$in: [id]
}
}
}, {
$unset: 'articles'
}]
}
},
{
$lookup: { // 2
from: 'users',
as: 'user',
pipeline: [{
$project: {
id: 1,
user_name: 1,
picture: 1
},
}, {
$match: {
blogs: {
$in: [...] // Передать сюда
}
}
}]
}
}
]
*
)?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question