How to serialize data for complex query

System Information
  • Strapi Version: 3.5.3
  • Operating System: ubuntu 18.04
  • Database: postgresql
  • Node Version: 14.13.1
  • NPM Version:
  • Yarn Version: 1.22.5

Normally I receive this response from get Category API
[
{
“id”: 1,
“Name”: “Sea Food”,
“Description”: “Sea Food restaurant”,
“published_at”: “2021-03-15T07:24:35.035Z”,
“created_at”: “2021-03-15T07:24:32.873Z”,
“updated_at”: “2021-03-15T07:24:35.049Z”,
“locations”: [
{
“id”: 1,
“display_name”: “The Piggery”,
“Description”: “# THE PIGGERY RESTAURANT & ROOFTOP\nThe Piggery is open for indoor dining! With 3 large dining rooms, we have all space to socially distance our guests. \n\nOur current hours: M-F: 3:00 pm to Close, Sat & Sun: 11:00 am to Close.\n\nIf you are looking for pickup or delivery, please order directly through us online or call 7732817447. We will be posting special menus and promotions available on by these ordering methods.”,
“published_at”: “2021-03-15T07:24:01.747Z”,
“created_at”: “2021-03-15T07:23:58.969Z”,
“updated_at”: “2021-03-17T12:31:48.007Z”,
“Working_hours”: {
“id”: 1,
“sat_mon”: “10am-3am”,
“tue_fri”: “10am-9pm”
},
“restaurant_images”: [
{
“id”: 1,
“name”: “syndicate-bar-lounge.jpg”,
“alternativeText”: “”,
“caption”: “”,
“width”: 550,
“height”: 367,
“formats”: {
“small”: {
“ext”: “.jpg”,
“url”: “/uploads/small_syndicate_bar_lounge_bbd4aeb8c9.jpg”,
“hash”: “small_syndicate_bar_lounge_bbd4aeb8c9”,
“mime”: “image/jpeg”,
“name”: “small_syndicate-bar-lounge.jpg”,
“path”: null,
“size”: 40.55,
“width”: 500,
“height”: 334
},
“thumbnail”: {
“ext”: “.jpg”,
“url”: “/uploads/thumbnail_syndicate_bar_lounge_bbd4aeb8c9.jpg”,
“hash”: “thumbnail_syndicate_bar_lounge_bbd4aeb8c9”,
“mime”: “image/jpeg”,
“name”: “thumbnail_syndicate-bar-lounge.jpg”,
“path”: null,
“size”: 10.33,
“width”: 234,
“height”: 156
}
},
“hash”: “syndicate_bar_lounge_bbd4aeb8c9”,
“ext”: “.jpg”,
“mime”: “image/jpeg”,
“size”: 50.48,
“url”: “/uploads/syndicate_bar_lounge_bbd4aeb8c9.jpg”,
“previewUrl”: null,
“provider”: “local”,
“provider_metadata”: null,
“created_at”: “2021-03-15T07:23:42.755Z”,
“updated_at”: “2021-03-15T07:23:42.763Z”
},
{
“id”: 2,
“name”: “menu-restaurant-vintage-table.jpg”,
“alternativeText”: “”,
“caption”: “”,
“width”: 500,
“height”: 333,
“formats”: {
“thumbnail”: {
“ext”: “.jpg”,
“url”: “/uploads/thumbnail_menu_restaurant_vintage_table_b44c2697f0.jpg”,
“hash”: “thumbnail_menu_restaurant_vintage_table_b44c2697f0”,
“mime”: “image/jpeg”,
“name”: “thumbnail_menu-restaurant-vintage-table.jpg”,
“path”: null,
“size”: 11.78,
“width”: 234,
“height”: 156
}
},
“hash”: “menu_restaurant_vintage_table_b44c2697f0”,
“ext”: “.jpg”,
“mime”: “image/jpeg”,
“size”: 34.27,
“url”: “/uploads/menu_restaurant_vintage_table_b44c2697f0.jpg”,
“previewUrl”: null,
“provider”: “local”,
“provider_metadata”: null,
“created_at”: “2021-03-15T08:07:51.722Z”,
“updated_at”: “2021-03-15T08:07:51.734Z”
},
{
“id”: 3,
“name”: “istockphoto-1018141890-612x612.jpg”,
“alternativeText”: “”,
“caption”: “”,
“width”: 612,
“height”: 408,
“formats”: {
“small”: {
“ext”: “.jpg”,
“url”: “/uploads/small_istockphoto_1018141890_612x612_729a148971.jpg”,
“hash”: “small_istockphoto_1018141890_612x612_729a148971”,
“mime”: “image/jpeg”,
“name”: “small_istockphoto-1018141890-612x612.jpg”,
“path”: null,
“size”: 29.71,
“width”: 500,
“height”: 333
},
“thumbnail”: {
“ext”: “.jpg”,
“url”: “/uploads/thumbnail_istockphoto_1018141890_612x612_729a148971.jpg”,
“hash”: “thumbnail_istockphoto_1018141890_612x612_729a148971”,
“mime”: “image/jpeg”,
“name”: “thumbnail_istockphoto-1018141890-612x612.jpg”,
“path”: null,
“size”: 9.84,
“width”: 234,
“height”: 156
}
},
“hash”: “istockphoto_1018141890_612x612_729a148971”,
“ext”: “.jpg”,
“mime”: “image/jpeg”,
“size”: 36.82,
“url”: “/uploads/istockphoto_1018141890_612x612_729a148971.jpg”,
“previewUrl”: null,
“provider”: “local”,
“provider_metadata”: null,
“created_at”: “2021-03-15T08:07:51.734Z”,
“updated_at”: “2021-03-15T08:07:51.749Z”
}
]
}
]
},
{
“id”: 2,
“Name”: “American Burger”,
“Description”: “Test TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest”,
“published_at”: “2021-03-15T10:25:36.950Z”,
“created_at”: “2021-03-15T10:25:36.957Z”,
“updated_at”: “2021-03-15T10:25:36.957Z”,
“locations”: []
}
]
But I am unable to restrict the attribute i.e suppose I wan’t only category name which is sea food and locations object and rest of thing is ignore then how to achieve it
Output should looks like this
[{
id:1
name: sea_food
locations:[{
id:1
display_name: the pigry
},
{
id:2
display_name: bla bla…
}]
},
{
id:2
name: American Burger
locations:[{
id:1
display_name: the pigry
},
{
id:2
display_name: bla bla…
}]
}]