Complete the code to subscribe to realtime updates on the 'messages' table.
const subscription = supabase.channel('public:messages').on('postgres_changes', { event: 'INSERT', schema: 'public', table: '[1]' }, payload => { console.log('New message:', payload.new); }).subscribe();
The subscription listens to inserts on the 'messages' table, so the table name must be 'messages'.
Complete the code to filter realtime updates to only rows where 'user_id' equals '123'.
const subscription = supabase.channel('public:messages').on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'messages', filter: 'user_id=eq.[1]' }, payload => { console.log('Updated message:', payload.new); }).subscribe();
The filter uses 'user_id=eq.123' to listen only for updates where user_id is 123.
Fix the error in the filter syntax to listen for deletes where 'status' is 'archived'.
const subscription = supabase.channel('public:files').on('postgres_changes', { event: 'DELETE', schema: 'public', table: 'files', filter: 'status=eq.[1]' }, payload => { console.log('Deleted file:', payload.old); }).subscribe();
The correct filter syntax uses 'eq' for equality in Supabase realtime filters.
Fill both blanks to subscribe to inserts on 'orders' where 'amount' is greater than 100.
const subscription = supabase.channel('public:orders').on('postgres_changes', { event: '[1]', schema: 'public', table: 'orders', filter: 'amount=[2].100' }, payload => { console.log('Large order:', payload.new); }).subscribe();
The event is 'INSERT' to listen for new orders, and the filter uses 'gt' to get amounts greater than 100.
Fill all three blanks to subscribe to updates on 'tasks' where 'priority' equals 'high' and 'completed' is false.
const subscription = supabase.channel('public:tasks').on('postgres_changes', { event: '[1]', schema: 'public', table: 'tasks', filter: 'priority=eq.[2]&completed=eq.[3]' }, payload => { console.log('High priority incomplete task:', payload.new); }).subscribe();
The event is 'UPDATE' to listen for changes, 'priority' filter is 'high', and 'completed' filter is 'false' to get incomplete tasks.
