Hi Everyone,
I’m new in mongodb and i want to create the collection from the pipeline aggregate.
I have 2 collections with this schema
1 - customer collection :
{
customerId
audienceId
integrationDate
processingDate
}
2 - audience Audience collection
{
audienceId,
name,
description,
createdDate,
updatedDate,
numberOfBurn,
offerValidityDays,
category,
buCode
}
And my goal is to have the third collection like this:
{
customerId,
buCode,
audiences
[
{
audience : {
audienceId,
name,
description,
createdDate,
updatedDate,
numberOfBurn,
offerValidityDays ,
category,
codeBU
},
processingDate,
integrationDate,
}
]
}
I tried this way but it’s not exactly the same
db.customer.aggregate([
{
$lookup:
{
from:"audience",
localField:"audienceId",
foreignField: "audienceId",
as: "audiences"
},
pipeline:[
{}
]
}
]).pretty()
Someone can help me please.