Passing DB Schema to Custom Function
Options
![Brian Giometti](https://us.v-cdn.net/6037124/uploads/userpics/ONIPTIEX0LDD/nJE4ZN6ATNTPB.png)
Brian Giometti
Member ✭
Is there an easy way to set the input to a custom function to match a table's schema? I see the database link which gives me alllllllllll the fields as inputs, but if I stick it in an object I don't get any of them.
The context of my question:
I've got a custom function that calculates a number of fields when a row is added or updated. Currently I'm just passing the row ID and having the function lookup and then update the records. As I start to use this function I realize this may not be the most efficient since I then need to :
1. create new record
2. pass ID to function
2a. lookup record
2b. update record
2c. return object
3. return object
So I guess the second part of the question is, are there notable performance benefits to passing and returning an object from the custom function (notable enough to outweigh the annoyance of linking all the fields every time I use the function, which stands in the 25ish range)
The context of my question:
I've got a custom function that calculates a number of fields when a row is added or updated. Currently I'm just passing the row ID and having the function lookup and then update the records. As I start to use this function I realize this may not be the most efficient since I then need to :
1. create new record
2. pass ID to function
2a. lookup record
2b. update record
2c. return object
3. return object
So I guess the second part of the question is, are there notable performance benefits to passing and returning an object from the custom function (notable enough to outweigh the annoyance of linking all the fields every time I use the function, which stands in the 25ish range)
Comments
-
Objects require you to build out all the schema which can be annoying if there is a lot. You probably want to use the json type.
-
Hmm that's an option I hadn't considered. I assume the only downside to JSON is making sure I'm addressing everything correctly, which is easy enough when I know what object is going to end up getting passed in.
-
I have the same question. But I found a way to auto-map values to the object's schema (add object input, add additional schema that is a database link, map var1 to the sub-schema of custom function + push a value to “@meta” key which is required for some reason). But the downside, just like with JSON is that one needs to address everything by hand withing the custom function.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback