Hye,
I want to ask if is this possible to run group two times and make the structure like this.
here is my sample of my documents
documents
[
{
users: ['A','B'],
speaker: 'C'
},
{
users: ['A','B'],
speaker: 'C'
},
{
users: ['D'],
speaker: 'C'
},
{
users: ['E','F'],
speaker: 'G'
},
{
users: ['H'],
speaker: 'C'
},
{
users: ['A','B'],
speaker: 'C'
},
{
users: ['E','F'],
speaker: 'G'
}
]
and the end goals to get structure like this
[
{
_id: 'C',
class: [
{
_id: ['A','B'],
sessions: [
{
{
users: ['A','B'],
speaker: 'C'
},
{
users: ['A','B'],
speaker: 'C'
},
{
users: ['A','B'],
speaker: 'C'
}
}
]
},
{
_id: ['D'],
sessions: [
{
users: ['D'],
speaker: 'C'
}
]
},
{
_id: ['C'],
sessions: [
{
users: ['H'],
speaker: 'C'
}
]
}
]
},
{
_id: 'G',
class: [
{
_id: ['E','F'],
sessions: [
{
users: ['E','F'],
speaker: 'G'
},
{
users: ['E','F'],
speaker: 'G'
}
]
}
]
}
]
for first layers group by speaker I am able to do it. but the second layer to push and group by users I am stuck there. hope someone able to help. thanks!