如何使用多个条件筛选Supabase Postgres CDC查询?
channel.on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'users',
filter: 'username=eq.Realtime' }, (payload) => {
console.log('All updates on users table when username is Realtime: ', payload)
})而不是:filter: 'username=eq.Realtime'
我想做的是:filter: 'username=eq.Realtime&&firstname=neq.test'
正确的方法是什么?
发布于 2022-11-28 05:44:21
目前,Supabase实时引擎只允许应用一个过滤器。在您的示例中,您只需忽略所有不符合好的旧if语句条件的数据。
channel.on('postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'users',
filter: 'username=eq.Realtime'
}, (payload) => {
// Check if the data meets the additional condition you would like.
if(payload.new.firstname == 'test') {
console.log('All updates on users table when username is Realtime: ', payload)
}
})https://stackoverflow.com/questions/74594066
复制相似问题