I have a dictionary like this with different permissions per users or per groups:
"permissions": [
{
"user": 4,
"type": "admin"
},
{
"user": 3,
"type": "read"
},
{
"group": 3,
"type": "admin"
}
]
What is the most efficient way to obtain a grouping by permission type:
The numbers represent id of objects(users/groups) so I also have to "translate" them a little bit in the result:
"permissions": [
{
"type": "admin",
"users":[
{"id":4}
],
"groups":[
{"id":3}
]
},
{
"type": "read",
"users":[
{"id":3}
]
},
]
Thanks for helping !