I have a table user_roles:
id | role | created_at |
---|---|---|
1 | admin | 2021-10-27 |
2 | developer | 2021-10-28 |
I would like to have the result returned as a map of json just like the format below:
{
"1":{
"id":"1",
"role":"admin",
"created_at":"2021-10-27"
},
"2":{
"id":"2",
"role":"developer",
"created_at":"2021-10-28"
},
}
Which SQL (Postgres) query should I use to get a result like this?