User-user connection table

Options
Hello,
I have a user table and I added an object with relationship to the same user table.
The object only adds user_id and doesnt add other fields like email, avatar etc into the list
and when I GET, it is the same.

What I want is, once I add a user, I want the object to contain all of the added user details

At the moment I am able to get around by adding manually, the fiels in the object space. But, the above will be clean if it can be achieved.

If this was addressed before, could you help point me to the appropriate link pls.

 

[Image]
At the beginning, it was just the below with drop down:
[Image]
I had to add the name, email, avatar manually/ or map via APIs by assigning variables and dot notation to add these:
[Image]

Any help will be greatly appreciated!!

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Hi  - it looks like all your images are broken, but I think I have enough context. So table references are always just references to the primary ID of the referenced table... You should check out Addons as they allow you to transform these table references into the related data from the table:

    https://docs.xano.com/working-with-data/addons
    
  • Prathyusha Chilagani
    Options
    Hi   ,
    Yes, I tried the add on!
    But, when I try to map the fields of my user table only the user.id shows up, where as the others do not.
    [image.png]
    My table has the other fields, email, username as well:
    [image.png]

    Maybe I am doing something wrong? But, I do not know what it is. 
    I added fields in a normal suggested fashion as in the videos. 

    ~Prathyusha 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     - yes if you watch the tutorial, the user.id would be how it connects the table, then the addon would be able return the other fields from the related table
  • Prathyusha Chilagani
    Options
     , yes. Thank you! I am able to see now. I somehow got confused. 
  • Prathyusha Chilagani
    Options
    
    Hello Michael,
    I created a reverse addon in this user-user scenario.
    If the first addon is MyPartners (the Users I added) which is an object array,
    The second add on is UsersWhoAddedMe (Users who added me) which is another object array

    Now, when I want to retireve a Users data, Ideally I want all my partners (those whom I added, and those who added me ) under 1 object list. SO, that this helps in front-end (the sole purpose of add-ons)
    but, I get this as two seperate objects.

    I just want them to be merged into "MyPartners"

    If I remove the name on the second Add-on it just lists as self and doesnt get added to the MyPartners Array.

    If I have the Add-on added inside of the MyPartners array without the name, it is getting added nested inside of each element of MyPartners. 

    And if I add outside of MyPartners Array by renaming the new add-on name to the old one - MyPartners, with an intention to merge, it lists only the new Add-on elements.

    I hope I put it intelligibily.

    [image.png]
    [image.png][image.png]
    ~Prathyusha 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     - when merging an Addon into an existing object there has to be an enforcement of hierarchy that takes place. For example, you already have fields in the "parent" object such as:

    {
    id:
    name:
    email:
    ...
    }

    The parent object is going to take priority over the addon when you merge the objects. Because your fields are the exact same in this example, you won't see them when you try to merge it into the parent object otherwise you would have multiple name, email, id, etc. fields leading to bad or confusing data. 
  • Prathyusha Chilagani
    Options
     
    erm...The objects are list of objects. 
    Say the out layer object is A and the list of objects inside it is "a". 
    And the new add on I created is an object B with a list of objects "b". 
    I cannot add "b" into A?
    so that A has a seamless list of objects a+b?
    I understand if the list itself isnt a list of objects it would it messy. 

    Thanks for taking the time. 

    ~Prathyusha 
  • Prathyusha Chilagani
    Options
     and for anyone who's looking into this..

    I just seperated the objects into seperate arrays and merged.
    I was confused in doing the same before, and was failing because the addon associates with the ID for user-connections.

    They HAVE to be called seperately via creating variables due to this, and cannot be merged as is.

    I took the help of this video:
    

    Thanks. 

    ~Prathyusha