If you can filter in the backend and not load all items, only items that are “favourite”, you can always apply this condition directly in the addon:
When you create the addon in the endpoint, this addon is created in the XANO library, there you can edit the addon and apply the query filter to only return items that are favourite.
I have the relationship on the User Table. So the User would have multiple favourite items. Should the relationship be the other way around? Wouldn’t that be more difficult? for an item to have multiple users that have added that item as favourite.
What I thought was that I can use an addon on the xano api and get the items by getting the user. But I’m not sure how to filter to the logged-in user.
I’m also using Xano backend but I’m trying to avoid such a relationships in a DB. I would put pinned_responses to a separate table and build queries via JOINS or Addons (which I prefer).
Then you only have to write a constrain user.id == auth.id on the Xano side an you are ready to go!
I’m using relationships as a list of objects (array) if there is only limited and predictable number of items.
When you create the Endpoint in the items, QUERY ALL records where all items are as favourite, where the QUERY all records conditions is user.id = items.user.id.
In the items table you can create a user reference field to enable the condition “user.id = items.user.id.”
@Dominic you don’t need to use “Get User Record” if you use AUTH during login, just add Id = Auth.id
And has @Dominic mentioned, it’s not good practices to pull data into the user collection unless specific user data itself.
Not home now, but later can printscreen the process.