Renaming fields in an addon

Answered

I am attempting to consolidate a 3 layer deep addon conundrum. Here is what the get record function looks like:

Now imagine I want the output to contain both the id of the organisation and of the user_organisation join table. As far as I can see I can't change the id field of any of the tables and I don't see how to create a column alias in the addon.

I ideally want to create something like this:

{
  "id": 1,
  "created_at": 1700145306513,
  "name": "dfdf",
  "email": "[email protected]",
  "organisations": [
    {
      "users_organisations_id": 1,
      "users_organisations_created_at": 1700145967463,
      "permissions": [
        "admin"
      ],
      "organisations_id": 1,
      "organisations_created_at": 1700145967463,
      "name": "lsla"
    }
  ]
}

Now I can write a custom function to do this of course but ideally, as it's just a matter of allowing me to specify alias' I wondered if I was missing something that can be done trivially?

4 replies