I have two tables posts and post_metas with the schema as below:
POSTS
+------------+------------------+
| Field | Type |
+------------+------------------+
| id | int(10) unsigned |
| title | varchar(255) |
| content | longtext |
POST_METAS
+------------+------------------+
| Field | Type |
+------------+------------------+
| id | int(10) unsigned |
| post_id | int(10) unsigned |
| key | varchar(255) |
| value | longtext |
using a simple one to many relationship, i get this output
[
{
"id": 1,
"title": "Dibbert LLC",
"content": null,
"post_metas": [
{
"key": "code",
"value": "YSRSLBZ7"
},
{
"key": "agent_id",
"value": "32"
}
]
}
]
I am wondering if it is possible to have the post metas as an object not an array, like this instead:
[
{
"id": 1,
"title": "Dibbert LLC",
"content": null,
"post_metas": {
"code": "YSRSLBZ7",
"agent_id": "32"
}
}
]