Displaying data on Agent page of agent data and cards of real estate objects assigned to the selected agent

Introductions:
For objects, there is a Properties page, which contains cards of real estate objects. If you click on a card, you will be taken to the Object page, where all object data is displayed.
For agents there is Agents page, which contains agent cards. If you click on a card, you will be passed to the Agent page. This page displays information about the agent and properties assigned to him.
Supabase has tables Properties and Agents. They are linked by the column agents in Properties and id in Agents.
Task:
Displaying data on Agent page of agent data and cards of real estate objects assigned to the selected agent.
Two object variables currentObject and currentAgent were created.

The transition from card to page is similar, so I will describe currentAgent as an example.
On the Agent_page transition page I added the id parameter.

I created a workflow for the agent card.


On the Agent page I take data for the agent from the variable currentAgent. The data of the objects assigned to the agent want to take from the Properties collection and filter by agent.

image

But it doesn’t work. Why?

Additionally, screenshots of Properties and Agents tables in Supabase.


Is there any other way to do it? I’m not very familiar with the code.

What I would suggest doing, also for better performances with big amounts of data, is to move this logic to your Supabase query, you can do it by doing the following:

  1. You will create a collection called for example “Get agent’s properties” in this collection, you get your Properties table and in the filters, you bind the currentAgent.id to the filter
  2. On the agent page load, you will fetch this collection, which will get only the data you need from your Supabase backend, instead of loading them all.

Also, if you’re considering having many properties, I’d suggest changing the agent type to int8 like you have with your id, because int2 has a maximal value of 32767, meaning at 32767 properties, you will run out of id’s. Standard for identity is int8.

1 Like

Thank you, that’s how it worked out.

And about int2, I don’t think there will be that many agents. But if it happens, I’ll change it then).