How to send custom json response from server action?

I have three table product, seller, slots. Each table contain a field called seller_id which connects the data between them. Here is the server action I want to perform.
I want to fetch all the products from the products table, then using the seller_id field value of the product I want to fetch the seller. Here the seller_id is unique in seller table, which means the response will be a single row. And the using the same technique I want to fetch the slots based on the seller_id value. Now, here the slots result can be multiple rows, because seller_id here is not unique. And I want all those data as an array in a single product items.

Simply speaking, this is how I want my result

{
  query:[
    {
      product:product_details,
      seller: seller_details,
      slots:[
           {
              slots:slot_details
          },
..........
         ]
    },
.
.
.
.
.
  ]
}

How can I develop a server action which takes less time interval ?

Community Page
Last updated: