Simplify data structure in addon

Options
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?

Comments

  • Wes Wagner
    Wes Wagner Member
    Options
    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.
  • Wes Wagner
    Wes Wagner Member
    Options
    I still haven't been able to accomplish this. I'll return to this in the evening.
  • Stefan Pointecker
    Options
    Any luck?  :)
  • Wes Wagner
    Wes Wagner Member
    Options
     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.
  • Stefan Pointecker
    Options
     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!
  • Wes Wagner
    Wes Wagner Member
    Options
     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.
  • Stefan Pointecker
    Options
     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]
  • Wes Wagner
    Wes Wagner Member
    Options
    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]
  • Stefan Pointecker
    Options
     actually I don't have a premiums field in my home entity. I only have the home_id in the premium entity.
  • Wes Wagner
    Wes Wagner Member
    Options
     Ah, I see. I suggest going to office hours or tagging a Xano team member then. This is different to the problem I had.