Adalo | many-to-many relationships in Xano
![GeneralJWS](https://us.v-cdn.net/6037124/uploads/userpics/VUFHSVIWSEYX/n2WQ4OHQ9FARV.jpg)
I'm trying to create a relationship between my Users and Posts. Right now, whenever I create a post it does not get assigned to a user. I would like to know how to make it to where I a user can create a post and that post belong to that user. Can someone help with this? This would help be tremendously.
Thanks!
Answers
-
I think you're looking for a one-to-many relationship: a single user goes with multiple posts, but a given post only goes with one user. That's much easier to manage. You can create a field in the posts table called “user_id” (or “owner_id” or what have you) that is a table reference to your users table. Then, as part of the API endpoint (or what have you) that runs “add record”, you add the current user ID (probably from auth:id) into that field. Voila, data connection.
if your data relationships are more complex, please share! Maybe I or others can help further.
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