Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Subscribe to Views / Multiple Rows / Multiple Columns #185

@jdgamble555

Description

@jdgamble555

Feature request

I would like to subscribe to a query itself, not a table. I don't need multiple subscriptions, just one for the query. If the query changes (not always important if INSERT, UPDATE, or DELETE), I would like my observable to get updated.

Currently, we can only use this complicated subscribe version of this query:

Promise

this.supabase.from(col).select('*').eq(field, value).single()

Subscription

this.supabase.from(${col}:${field}=eq.${value}).on('*', (payload) => {})

Is your feature request related to a problem? Please describe.

  • The eq should be a separate method
  • Every other method on the promise version should be available (gt, ls, filter, like, etc).
  • Views should be available for subscriptions (NOT CLEAR AT ALL)

Describe the solution you'd like

this.supabase.from(col).select('*').eq(field, value).single()
  .subscribe((snap) => {
    if (snap.type === 'added') {
     console.log(snap.data);
    }
  });

V2 is Getting MORE Complicated, and LESS Intuitive

https://supabase.com/blog/supabase-js-v2

supabaseClient
  .channel('any_string_you_want')
  .on(
    'postgres_changes',
    {
      event: 'INSERT',
      schema: 'public',
      table: 'movies',
    },
    (payload) => {
      console.log(payload)
    }
  )
  .subscribe()

While the multiplayer mode looks cool, let's complete the actual limitations of the current realtime data before moving on to more features!

  • Channel names could be automatic (perhaps with UUID in the background) if we don't want to select a channel.
  • These classes and methods are MORE confusing, and don't help basic use cases.
  • This would also be useful in order to add GraphQL Subscription support.
  • I realize RLS is the biggest issue here.
  • Just allowing VIEWS to be subscribed to would solve this problem for now.

Describe alternatives you've considered

I don't think there should be an alternative. In order for it to be easy, it should work just like the regular queries, but with a subscription.

All of these Database work the exact same way in Query mode as Subscription mode, and allow complex queries (as far as the database itself can handle):

Additional context

Related:
supabase/realtime#271
#97
supabase/supabase#1206
supabase/realtime#222
supabase/supabase#3193
supabase/supabase#3748
supabase/supabase#5684
supabase/supabase#7735

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions