I have two collections “datasets” and “users” both having an array of object fields.
datasets inside stateHistory array object having date fields.
users inside some of the users have a prices array of object date fields
I need to join stateHistory.date === prices.date fields
I need an output of
"datasets": [
{
"eyeSize": 54,
"bridgeSize": 15,
"templeLength": 135,
"colorCode": "F010",
"colorDescription": "braun, rose gold",
"cgPrices": 200,
"stateHistory": [
{
"state": "scanning",
"date": "2022-02-22T13:06:13.493+00:00",
},
{
"state": "scanned",
"date": "2022-02-18T13:06:13.493+00:00",
},
{
"state": "reconstructing",
"date": "2022-02-16T13:06:13.493+00:00",
}
]
},
{
"eyeSize": 54,
"bridgeSize": 15,
"templeLength": 135,
"colorCode": "F011",
"colorDescription": "beige, silber",
"stateHistory": [
{
"state": "scanning",
"date": "2022-03-22T13:06:13.493+00:00",
},
{
"state": "scanned",
"date": "2022-03-18T13:06:13.493+00:00",
},
{
"state": "reconstructing",
"date": "2022-03-16T13:06:13.493+00:00",
}
]
}
]
my code: Mongo playground