Realtime listener with multiple constraints
# help-and-questions
z
Hi, I'm creating a realtime listener to listen to changes in my bids table. Each bid has a reservation_id to signify what reservation the bid belongs to. For my listener, I need to listen to make sure it doesn't listen to all bids, but only where the bid's reseveration equals "x", "y" or "z". Here is what I have now:
Copy code
js
 useEffect(() => {
    const bidsSubscription = supabase
      .channel("any")
      .on(
        "postgres_changes",
        {
          event: "*",
          schema: "public",
          table: "bids",
        },
        (payload) => {
          console.log(payload);
        }
      )
      .subscribe();

    return () => {
      supabase.removeAllChannels();
    };
  }, []);
I understand I can filter like
filter: 'reservation_id=x'
but can I chain these together?
g
No it is a single filter. You would need to add a generated column on the table and concatenate data and compare that depending on your filters working for that case.
You also have an .in() type filter if your values are all on the same column. That uses an array to compare to the column.
z
would it be possible to just create a real-time listener for every reservation and since each reservation has a one to many relationship to bids, and recieve the data that way?
g
If you are just looking at one column then use the in filter.
But yes, if you have several different filters that are OR'd together you can do multiple subscriptions.
z
are there any docs related to
in
in the context of realtime listners?
I guess I am just unclear on the correct syntax. Like can I use the in, inside the filter for realtime?
z
perfect!