Get the records only belonging to a specific user
Options
![Gavril Loghin](https://us.v-cdn.net/6037124/user_avatars/2329389.jpg)
Gavril Loghin
Member ✭
Greetings!
Quick question: I have 2 tables: one for users and one for projects. How can I get the records only belonging to a specific user? Thank you.
Thank you.
Quick question: I have 2 tables: one for users and one for projects. How can I get the records only belonging to a specific user? Thank you.
Thank you.
Comments
-
you mean how can you query those records or how you can map them?
if it is about the latter, just created a column in project table that will have relationship with user table e.g. through id so that you can query only specific user from project table in future -
Lukasz is right... then in your Query All Records function > Filter > By Custom Query you can set db: projects.user_id = input: user_id (or auth id if you require authentication for that endpoint)
-
Many thanks, and ! I think I am missing something. So what I try to achieve is to make a POST request to the projects table and after that to build a page that will return all of those posted projects based on your authentication. I am using Draftbit for my front-end but I followed this tutorial to have a look at the required API endpoints:
https://www.youtube.com/watch?v=Mjy6PdZUM8g&t=76s
User table
[Screen Shot 2021-11-17 at 14.35.22.png]
Projects table
[Screen Shot 2021-11-17 at 14.35.00.png]
Filter by custom query
[Screen Shot 2021-11-17 at 14.44.26.png]
Testing result
[Screen Shot 2021-11-17 at 14.35.51.png]
The only thing that I don't understand now is when I test the GET/projects endpoint the result is [0]. -
None of your records in your projects table are related to a user record. So no projects belong to a user - there is no data in your projects.user_id field
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