Best practice to pass/map variables to custom function

Options
Valentin R
Valentin R Member
edited February 2023 in ? Help! I'm a Noob

I'm sometimes dealing with situations when I have a few custom functions nested under each other. Let's say I get a user profile data (30+ key-value pairs) from db in the first one, but then I need to use these same keys-values in a custom function underneath. What would be the best practice to pass them to that function?

1. Pass just the db entry id and pull data from db again in sub-fuction? Seems wrong.
2. Add inputs for sub-function as a database link (quick and easy) and then map variables to from function 1 to function 2? (seems like this can only be done manually for each key-value)
3. Pass an object to function 2 and add a schema that is “table reference”? I did it but it still involves manual mapping of every field.

Answers

  • Valentin R
    Options

    #3 — I found the way to map the data to the object, had to map it not the the object itself but to the sub-entity of it which has the scheme that is a table reference.. However, for some reason the object expects some “@meta” json as part of the object and I get this:

    {"code":"ERROR_CODE_INPUT_ERROR","message":"Missing param: @meta","param":"contact.data.@meta"}

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    I often use the JSON type instead of the object so I don't have to write out all that schema. You get the same functionality, though with some fewer guardrails. I find the benefit in (dev) speed is worth it.