Simplify data structure in addon
Options
Stefan Pointecker
Member ✭
hey again,
I am having a customer table and a premium table.
A customer can have multiple premium entries.
I added a addon which queries the premium table via a few fields to load the related data for a customer (start, end date, active).
Now I got the list of premium entries for a customer. But I would prefer to have a simpler structure, currently I am having an array with objects in it.
It would be easier to just have an array with the name of the premium entry.
See screenshot:[Bildschirmfoto 2022-07-22 um 11.23.20.png]Is that even possible?
I am having a customer table and a premium table.
A customer can have multiple premium entries.
I added a addon which queries the premium table via a few fields to load the related data for a customer (start, end date, active).
Now I got the list of premium entries for a customer. But I would prefer to have a simpler structure, currently I am having an array with objects in it.
It would be easier to just have an array with the name of the premium entry.
See screenshot:[Bildschirmfoto 2022-07-22 um 11.23.20.png]Is that even possible?
Comments
-
I know this is possible, but it isn't clear to me what the simplest approach is for achieving the desired results. I'm currently working on this and will send a reply with how I accomplish it.
-
I still haven't been able to accomplish this. I'll return to this in the evening.
-
Any luck? :)
-
Yep! It's a bit hard to describe how to do it without knowing your current setup. Feel free to record a screenshot a setup of that field in the database (the settings and type) as well as record how you setup the API endpoint and add-on. If you share that here, I'll provide feedback.
For me, I realized I had set up the table reference / database incorrectly, which made it much harder than it should have been. But it's hard to tell if that's the case here for you with just the screenshot. -
hey, there you go I hope this helps.
premium structure:[Bildschirmfoto 2022-07-29 um 09.04.10.png]
"home" would be the "customer" in this case. so there is no reference for "premium" in the "home" table.
this is the connected addon in the GET home endpoint:[Bildschirmfoto 2022-07-29 um 09.06.59.png]
this is the detailled addon view:[Bildschirmfoto 2022-07-29 um 09.08.03.png]let me know if you need more! -
Change the output type on the addon from type "list" to type "single" and let me know how it goes. This was exactly my problem as well.
-
then I only have a single item, although through db relations there should be 2 items.[Bildschirmfoto 2022-07-29 um 15.51.08.png]
-
If I'm understanding correctly, the premiums database field should be set up like this—a list of integers. Is that how it's currently configured?[Screen Shot 2022-07-29 at 9.58.01 AM.png]
-
actually I don't have a premiums field in my home entity. I only have the home_id in the premium entity.
-
Ah, I see. I suggest going to office hours or tagging a Xano team member then. This is different to the problem I had.
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