Nest response from Server Actions

Is there a simple way of nesting the response from server actions ?
To something like this:

{
  "user": {
     "active_shift": [],
     "last_shifts": []
  },
}

image

Instead of:
image

Tried adding a repeat after user but more or less the same.
Possible to do in one big custom query ?

Hey Mattis,

See if this works for you:

Screen Shot 2020-11-01 at 3.34.51 PM

produces:

{
  "user": {
    "active_shifts": [
      {
        "shift_id": 1
      }
    ],
    "last_shifts": [
      {
        "shift_id": 1
      }
    ]
  }
}

Thanks Ken,

Almost perfect :slight_smile:
How could I modify it to also grab data from the user (email, fname etc…)
Tried enabling various outputs but did not work as intended

{
  "user": {
 **"email",
 **"fname",
    "active_shifts": [
      {
        "shift_id": 1
      }
    ],
    "last_shifts": [
      {
        "shift_id": 1
      }
    ]
  }
}

Hey, no fair adding new requirements! :wink:

You have to select the fields to include, on the repeat.

produces:

{
  "user": {
    "user_id": 1,
    "username": "mebeingken",
    "email": "ken@uniqueideas.com",
    "active_shifts": [
      {
        "shift_id": 1
      }
    ],
    "last_shifts": [
      {
        "shift_id": 1
      }
    ]
  }
}
1 Like

Awesome, works as intended.

I was using a single query to initially query the user and could not set any of the output fields on the repeat. After changing to normal query the outputs are available :+1:

1 Like