Addon with an object / multiple reference

Options

Hello!

I want to make an Addon of a table column that is an object. I don't know how to do it or what to type in the route. (see screenshot)

I have a table of users that has a connection to a "competences" table. So a user can have multiple competences assigned to him. I know how to do it with only a single reference, but not with a multiple reference (object).

Can someone help? Thanks!
[Bildschirmfoto 2022-02-28 um 16.18.01.png][Bildschirmfoto 2022-02-28 um 16.16.29.png]

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    I'm not sure you can do this with addons as they are set up today. (others might set me straight on that.)

    Apparently, you can do that! See 's comment below!

    But - assuming no crazy details - you can generate the same effect for your API or function output using a little bit of clever function stack code. Just spinning some pseudo-code: 

    1) Iterate over your users
    2) For each user, 
    a) pull the competence_id into a variable
    b) initialize a blank array
    c) Iterate over the competence_id to 
        i) get  competence
        ii) add the competence to the end of the array
    d) Add the array to your user
    3) return the users! 

    Let me know if you'd like to discuss this more - showing can be easier than telling, and concerns specific to your use case will drive how complex this needs to be, and where you might be able to get performance! 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     addons can 100% handle this use-case. Also, just to clarify, your column appears to be an array not an object - it is a list of table references correct?

    Make sure to create your addon from inside the array as prompted, for example:
    [CleanShot 2022-02-28 at 14.45.04.png]
  • Noof Soud
    Noof Soud Member
    Options
     I have same issue, could you please showing me how ? in video - Thank you
  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
     Michael's reply also on this thread shows how to solve this use case much more simply than the steps I laid out above. If it works for you, could save some time! 
  • Kyan Lynch
    Kyan Lynch Member
    Options
    I have this exact same use case but can't get this to work from me. I create the addon from inside the array as indicated, but it's not actually adding anything on to the result
  • Kyan Lynch
    Kyan Lynch Member
    Options
    Some images that may be helpful:

    Result before add-on:[Pre-addon.png]Output Structure before addon:
    [pre-addon output.png]Output structure with addon:
    [addon mapped.png]Result after addon:
    [post-addon result.png]
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     how do you have the Addon mapped? Can you provide a screenshot?