I have the following collection in MongoDB
I want to create a list for each account
for which I created a dataset with the following query
{ runCommand : { aggregate : 'case',
pipeline : [ { $project : { accounts : 1 }},
{ $unwind : '$accounts'}
]
}
}
Now inside the list I want to represent the transactions
array in a table. I am not able to figure out what dataset query should I use for it. Currently I am using this
{ runCommand : { aggregate : 'case',
pipeline : [ { $project : { accounts : 1 }},
{ $unwind : '$accounts'},
{ $unwind : '$accounts.transactions'}
]
}
}
But the result I get is wierd. I get 3 tables but each table has all the transactions
in all 3 accounts
. I think I need to group them somehow with accountNumber
as it is unique to each account but I cannot figure out the corresponding mongo query. Need some help please.