Answer the question
In order to leave comments, you need to log in
Aggregation from two collections?
Guys, help to form a request. There are two collections with the following document structures
db.xcover
{
"_id" : ObjectId("5b101caddcab7850a4ba32eb"),
"connections" : [
169906699,
125629607
],
...other-fields
}
db.dcover
{
"_id" : 169906699,
"changed" : true,
"time" : false,
...other-fields
}
db.dcover.aggregate([
{
$match: {
$or: [{ changed: true }, { time: true }]
}
},
{
$lookup: {
from: 'xcover',
localField: '_id',
pipeline: [
{ $match: { $expr: { $in: ['$_id', '$xcover.connections'] } } },
{ $unwind: '$xcover' }
],
as: 'xcover'
}
}
])
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