How can i add a Result of thing created, in to a users table in Xano

Hi Guys, im new ate bubble, and Xano. So with bubble everything is easy, when with one click we can create a thing and edit a thing as well, but in Xano i cant figure it out how to do this


I want to create a “Morada” (address), and add the “Morada” (address) create to the current user.

Creation of “Morada”

Trying to add the “Morada” in the current user:

when i was using bubble, was easy because we have an option “Result of…” to add where we want

What is the best way to the this? what am i doing wrong?

Does it always get added to the user after being created? If it does, why not just edit the create endpoint to then link it to the user based on the user auth? That would be simpler.

After the Address being created have to be added to the current user, these is one of the examples on many similar thing a want to do.

In bubble is simple, but with the plugin Xano connector i cant figure it out

@pablopy100 The thing is, once you go with Xano, you are supposed to have EVERYTHING in Xano, including the users. You are no longer supposed to use the Bubble User table, as everything in Xano is based on User authentication. And no more privacy rules like Bubble either. You have to do all the security checks by adding checks in the Xano function stack, for every single API call, based on the context and security considerations of the call.

If you are new to Bubble and Xano, you will have a hard time doing this without some basic understanding of databases, security, and the basic principles of web development. My advice: keep it all in Bubble, or get ready to go through some serious training to level up :slight_smile:

I would start with proper understanding of database modeling: Entity–relationship model - Wikipedia

The User table its in Xano as well.

When a row is created in this table:

Must be added in the user table, in the column “morada”:

But its not passing the data, and i dont know how

Hey use the “Xano action returns the response” event, then call the api to update the current user. In such way, you always have the response from the first step.

6-weeks Xano Cohort Program Buy Xano Cohort Program

This what I meant about proper database modeling. You do not need to do it with 2-way linking like in Bubble.

In standard database design, with very few exceptions, you NEVER store a list of things in a column. I notice many of your columns have [integer] vs just integer. You are storing lists of things everywhere. That is one of the fundamental basics of relational databases. It is called “normalization” (see Database normalization - Wikipedia). You REALLY need to understand this before you do anything else. At least the basics of it. Forget about the more evolved normal forms after 3NF for now. Many things you learned from Bubble are just wrong in the context of more evolved database systems like Xano. “Welcome to the real world Neo” :grin:

Typically, you would only need to reference “user_id” in the “morada” table, which I am guessing is “household” in Portuguese. That is if only one user can own the “morada”.

Otherwise, if one user can have several different “moradas”, and if one “morada” can be attached to multiple different users, you would create what is called an “associative” table in Xano, which would have 2 columns: “Morada_ID”, and “User_ID”. We can call that table, for example, “Morada_Users”.

And then, you would first create the “Morada”, and, in Xano, use the result of the created “Morada” in the function stack, to then insert into “Morada_Users” table. You can do it all directly in Xano.

Here is a simple example in a Bubble + Xano app I am currently working on. When we create a new client in the system, we have many other dependencies and other things we need to create for that client. Here I have it inside a separate function, to keep things easier to read and maintain.

But the principle is the same: I first create the client, then the result of the newly created client is contained in the “client” var. And then, I call my function, passing it the result of “client” → id, which is the client ID of the client I just created, which I can then use to reference in other tables that have a “client_id” as a column and create the additional data.

I hope this helps… :slight_smile:

And one last thing… if you are then wondering “but if I store the data outside the users table, how will I get the Moradas list for a specific user” ? Then you need to learn about “Addons” in Xano. Addons allow you to return complex data structures from multiple tables in a single call. See Addons (GraphQL-like) | Xano Documentation :slight_smile:

Here is an example, where, from a “candidates” table, I also return the linked data from the associated “users” table, as well as data from linked tables about the groups a candidate is part of. All in one single Xano query :wink:

In this example, “GroupeCandidat” is an associative table that associated a group ID with a candidate ID. One candidate can belong to multiple groups, but one group can have many different candidates. Just like your Users + Moradas :slight_smile:

Thanks bro, i will try it out

Hey @ankur1 , already did it, but not working