Hi, I’m really newby and apology for the stupid question.
I have two douments and I need to do a left join counting the right elements.
Let me explain:
this is the first document
{
"id": "string"
, "matches": [
{ "timeMatch": "string"
, "matchID": "string"
, "opponentName": "string"
, "playerPoint": 0
, "opponentPoint": 0 }
]
}
This is the second
{ "matchID": "string", "boards": [ {
"round_mum": 0,
"board": [
{
"hexName": "string",
"who": "string",
"round": 0,
"score": 0,
"multiplier": 0,
"color": 0,
"status": 0
}
]
}]}
I need to have all lines of the first document putting the aggregate information from the second mantaining onli the MatchID and sum of board
The possible result could be
"id": "AAAA",
"matches" : [
id: "BBBBB" , board : 2
,id: "CCCCC" , board : 4
,id: "DDDDD" , board : 6
]
I use c# and I tryed do this kind of aggregation
var docs = FirstCollection.Aggregate()
.Lookup("SecondCollection", "MatchID", "id", @as: "match")
.Unwind("match")
.As<BsonDocument>()
.ToEnumerable();
and I don’t know hot to group the second counting the boards
Someone can help me?