Query a users relational records in Xano

Hi,

I’ve run into an issue with filtering a collection. My app has a Xano data with 3 tables. Users, Companies and Loads.

The user table has a relational field to the Company table (company_id). The loads field has a relational field to the Company field (company_id). So this would mean a company has many loads and many users.

I created a customer API endpoint in Xano for the loads table that takes an input of (company_id). When a user logs in, I want to display a table of that users companies loads.

When I go to setup the collection in Weweb I run into an issue binding the company_id input the API requires with the users stored company_id. The only fields available to me are user_id, created_at, name, email, role etc…

I tried to look back through the Xano Auth setup to see if there was something I was missing in making this extra field available for the user but haven’t been able to find anything.

My ultimate goal with this setup is to allow multiple users to belong to and post available loads under the same company. If there is a better way to set this up I am all ears but I would also like help making this relational field available for binding in weweb.

Well that didn’t take long but I figured it out :slight_smile:

If anyone comes across this post in the future, my issue was location in Xano and the output of the auth/me endpoint. Under the function stack, I needed to update the output from Get Record from USER to include the company_id.

After refreshing all my connections the company_id became available under the user auth in weweb.

2 Likes

What I like to do is also filter the GET endpoints in Xano by the user auth id (from the auth token) by default, so you know that the data is filtered for the current user by default :wink: