Get the records only belonging to a specific user

Options
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.

Comments

  • Lukasz Kwiatkowski
    Options
    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 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    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)
  • Gavril Loghin
    Options
    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].
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    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