Skip to content

Updated

Postgres Changes filters

Send each subscriber only the changes it needs.

Pass a filter in the filter parameter of a Postgres Changes subscription.

Realtime offers filters so you can specify the data your client receives at a more granular level. A filter is a column=operator.value expression (for example id=eq.1 or title=like.%foo%) that Realtime evaluates on the server, so filtered-out events never leave the database.

The following operators are available:

OperatorMatches when the column…Example
eqequals the valueid=eq.1
neqdoes not equal the valuestatus=neq.done
lt / lteis less than / less than or equal toage=lt.65
gt / gteis greater than / greater than or equal toquantity=gte.10
inis one of a list (max 100 values)name=in.(red,blue)
like / ilikematches a pattern (case-sensitive / insensitive)title=like.%foo%
match / imatchmatches a POSIX regex (case-sensitive / insensitive)slug=match.^post-
isIS null / true / false / unknowndeleted_at=is.null
isdistinctis distinct from the value (NULL-safe !=)state=isdistinct.active

You can also negate any operator with not. and combine multiple conditions with commas (applied as an AND).

Equal to (eq)

To listen to changes when a column's value in a table equals a client-specified value:

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'messages',
filter: postgresChangesFilter().eq('body', 'hey'),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'messages',
filter: 'body=eq.hey',
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.update,
schema: 'public',
table: 'messages',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.eq,
column: 'body',
value: 'hey',
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
UpdateAction.self,
schema: "public",
table: "messages",
filter: .eq("body", value: "hey")
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
table = "messages"
filter = "body=eq.hey"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"UPDATE",
schema="public",
table="messages",
filter="body=eq.hey",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "messages", ListenType.Updates, "body=eq.hey"));
channel.AddPostgresChangeHandler(ListenType.Updates, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

This filter uses Postgres's = filter.

Not equal to (neq)

To listen to changes when a column's value in a table does not equal a client-specified value:

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'messages',
filter: postgresChangesFilter().neq('body', 'bye'),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'messages',
filter: 'body=neq.bye',
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'messages',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.neq,
column: 'body',
value: 'bye',
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
UpdateAction.self,
schema: "public",
table: "messages",
filter: .neq("body", value: "hey")
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
table = "messages"
filter = "body=neq.bye"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"INSERT",
schema="public",
table="messages",
filter="body=neq.bye",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "messages", ListenType.Inserts, "body=neq.bye"));
channel.AddPostgresChangeHandler(ListenType.Inserts, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

This filter uses Postgres's != filter.

Less than (lt)

To listen to changes when a column's value in a table is less than a client-specified value:

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'profiles',
filter: postgresChangesFilter().lt('age', 65),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'profiles',
filter: 'age=lt.65',
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'profiles',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.lt,
column: 'age',
value: 65,
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
InsertAction.self,
schema: "public",
table: "profiles",
filter: .lt("age", value: 65)
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {
table = "profiles"
filter = "age=lt.65"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"INSERT",
schema="public",
table="profiles",
filter="age=lt.65",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "profiles", ListenType.Inserts, "age=lt.65"));
channel.AddPostgresChangeHandler(ListenType.Inserts, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

This filter uses Postgres's < filter, so it works for non-numeric types. Make sure to check the expected behavior of the compared data's type.

Less than or equal to (lte)

To listen to changes when a column's value in a table is less than or equal to a client-specified value:

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'profiles',
filter: postgresChangesFilter().lte('age', 65),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'profiles',
filter: 'age=lte.65',
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'profiles',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.lte,
column: 'age',
value: 65,
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
InsertAction.self,
schema: "public",
table: "profiles",
filter: .lte("age", value: 65)
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
table = "profiles"
filter = "age=lte.65"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"UPDATE",
schema="public",
table="profiles",
filter="age=lte.65",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "profiles", ListenType.Updates, "age=lte.65"));
channel.AddPostgresChangeHandler(ListenType.Updates, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

This filter uses Postgres' <= filter, so it works for non-numeric types. Make sure to check the expected behavior of the compared data's type.

Greater than (gt)

To listen to changes when a column's value in a table is greater than a client-specified value:

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'products',
filter: postgresChangesFilter().gt('quantity', 10),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'products',
filter: 'quantity=gt.10',
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'products',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.gt,
column: 'quantity',
value: 10,
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
InsertAction.self,
schema: "public",
table: "products",
filter: .gt("quantity", value: 10)
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
table = "products"
filter = "quantity=gt.10"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"UPDATE",
schema="public",
table="products",
filter="quantity=gt.10",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "products", ListenType.Inserts, "quantity=gt.10"));
channel.AddPostgresChangeHandler(ListenType.Inserts, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

This filter uses Postgres's > filter, so it works for non-numeric types. Make sure to check the expected behavior of the compared data's type.

Greater than or equal to (gte)

To listen to changes when a column's value in a table is greater than or equal to a client-specified value:

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'products',
filter: postgresChangesFilter().gte('quantity', 10),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'products',
filter: 'quantity=gte.10',
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'products',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.gte,
column: 'quantity',
value: 10,
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
InsertAction.self,
schema: "public",
table: "products",
filter: .gte("quantity", value: 10)
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
table = "products"
filter = "quantity=gte.10"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"UPDATE",
schema="public",
table="products",
filter="quantity=gte.10",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "products", ListenType.Inserts, "quantity=gte.10"));
channel.AddPostgresChangeHandler(ListenType.Inserts, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

This filter uses Postgres's >= filter, so it works for non-numeric types. Make sure to check the expected behavior of the compared data's type.

Contained in list (in)

To listen to changes when a column's value in a table equals any client-specified values:

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'colors',
filter: postgresChangesFilter().in('name', ['red', 'blue', 'yellow']),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'colors',
filter: 'name=in.(red,blue,yellow)',
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'colors',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.inFilter,
column: 'name',
value: ['red', 'blue', 'yellow'],
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
InsertAction.self,
schema: "public",
table: "products",
filter: .in("name", values: ["red", "blue", "yellow"])
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
table = "products"
filter = "name=in.(red,blue,yellow)"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"UPDATE",
schema="public",
table="products",
filter="name=in.(red,blue,yellow)",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "colors", ListenType.Inserts, "name=in.(red,blue,yellow)"));
channel.AddPostgresChangeHandler(ListenType.Inserts, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

This filter uses Postgres's = ANY. Realtime allows a maximum of 100 values for this filter.

Pattern matching (like, ilike)

To listen to changes when a text column matches a pattern, use like (case-sensitive) or ilike (case-insensitive). Use % to match any sequence of characters and _ to match a single character.

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'articles',
// matches "Breaking News", "BREAKING", ...
filter: postgresChangesFilter().ilike('title', '%breaking%'),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'articles',
filter: 'title=ilike.%breaking%', // matches "Breaking News", "BREAKING", ...
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'articles',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.ilike,
column: 'title',
value: '%breaking%',
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
InsertAction.self,
schema: "public",
table: "articles",
filter: .ilike("title", value: "%breaking%")
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {
table = "articles"
filter = "title=ilike.%breaking%"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"INSERT",
schema="public",
table="articles",
filter="title=ilike.%breaking%",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "articles", ListenType.Inserts, "title=ilike.%breaking%"));
channel.AddPostgresChangeHandler(ListenType.Inserts, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

like uses Postgres's LIKE and ilike uses ILIKE. Both require a text-compatible column. The examples above use ilike; swap in like for case-sensitive matching—usage is otherwise identical.

Regular expression matching (match, imatch)

To listen to changes when a text column matches a POSIX regular expression, use match (case-sensitive) or imatch (case-insensitive).

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'posts',
// matches "post-1", "post-42", ...
filter: postgresChangesFilter().match('slug', '^post-\\d+$'),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'posts',
filter: 'slug=match.^post-\\d+$', // matches "post-1", "post-42", ...
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'posts',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.match,
column: 'slug',
value: r'^post-\d+$',
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
InsertAction.self,
schema: "public",
table: "posts",
filter: .match("slug", value: "^post-\\d+$")
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {
table = "posts"
filter = "slug=match.^post-\\d+$"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"INSERT",
schema="public",
table="posts",
filter="slug=match.^post-\\d+$",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "posts", ListenType.Inserts, @"slug=match.^post-\d+$"));
channel.AddPostgresChangeHandler(ListenType.Inserts, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

match uses Postgres's ~ operator and imatch uses ~*. Both require a text-compatible column, and the pattern is validated when you subscribe. The examples above use match; swap in imatch for case-insensitive matching—usage is otherwise identical.

Null and boolean checks (is)

To listen to changes when a column IS null, true, false, or unknown, use is. is.null works on any column type; is.true, is.false, and is.unknown require a boolean column.

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'todos',
// only rows that are not yet completed
filter: postgresChangesFilter().is('completed_at', null),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'todos',
filter: 'completed_at=is.null', // only rows that are not yet completed
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.update,
schema: 'public',
table: 'todos',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.isFilter,
column: 'completed_at',
value: null,
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
UpdateAction.self,
schema: "public",
table: "todos",
filter: .is("completed_at", value: .null)
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
table = "todos"
filter = "completed_at=is.null"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"UPDATE",
schema="public",
table="todos",
filter="completed_at=is.null",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "todos", ListenType.Updates, "completed_at=is.null"));
channel.AddPostgresChangeHandler(ListenType.Updates, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

This filter uses Postgres's IS operator.

Distinct from (isdistinct)

isdistinct is a NULL-safe inequality (IS DISTINCT FROM). Unlike neq, it treats null as a comparable value, so a null column is considered distinct from a non-null value.

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'orders',
// includes rows where status is null
filter: postgresChangesFilter().isDistinct('status', 'shipped'),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'orders',
filter: 'status=isdistinct.shipped', // includes rows where status is null
},
(payload) => console.log(payload)
)
.subscribe()
supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.update,
schema: 'public',
table: 'orders',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.isDistinct,
column: 'status',
value: 'shipped',
),
callback: (payload) => print(payload))
.subscribe();
let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
UpdateAction.self,
schema: "public",
table: "orders",
filter: .isDistinct("status", value: "shipped")
)
await myChannel.subscribe()
for await change in changes {
print(change.record)
}
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
table = "orders"
filter = "status=isdistinct.shipped"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"UPDATE",
schema="public",
table="orders",
filter="status=isdistinct.shipped",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "orders", ListenType.Updates, "status=isdistinct.shipped"));
channel.AddPostgresChangeHandler(ListenType.Updates, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

Negating a filter (not

Prefix any operator with not. to invert it — for example not.in, not.is, or not.like.

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: '*',
schema: 'public',
table: 'posts',
// anything except drafts and archived
filter: postgresChangesFilter().not('status', 'in', ['draft', 'archived']),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: '*',
schema: 'public',
table: 'posts',
filter: 'status=not.in.(draft,archived)', // anything except drafts and archived
},
(payload) => console.log(payload)
)
.subscribe()

Set negate: true on a PostgresChangeFilter to apply the not. prefix.

supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.all,
schema: 'public',
table: 'posts',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.inFilter,
column: 'status',
value: ['draft', 'archived'],
negate: true,
),
callback: (payload) => print(payload))
.subscribe();

Wrap any single-condition filter in .not(...).

let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
AnyAction.self,
schema: "public",
table: "posts",
filter: .not(.in("status", values: ["draft", "archived"]))
)
await myChannel.subscribe()
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction>(schema = "public") {
table = "posts"
filter = "status=not.in.(draft,archived)"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"*",
schema="public",
table="posts",
filter="status=not.in.(draft,archived)",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "posts", ListenType.All, "status=not.in.(draft,archived)"));
channel.AddPostgresChangeHandler(ListenType.All, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

Combining filters with AND

Combine multiple conditions by separating them with commas. All conditions must match (logical AND). You can only combine conditions with AND — OR is not supported.

The builder composes conditions and escapes reserved characters for you.

const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'orders',
// amount > 100 AND status = "open"
filter: postgresChangesFilter().gt('amount', 100).eq('status', 'open'),
},
(payload) => console.log(payload)
)
.subscribe()
const channel = supabase
.channel('changes')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'orders',
filter: 'amount=gt.100,status=eq.open', // amount > 100 AND status = "open"
},
(payload) => console.log(payload)
)
.subscribe()

Pass a list of filters to filters to combine them with AND.

supabase
.channel('changes')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'orders',
filters: [
PostgresChangeFilter(
type: PostgresChangeFilterType.gt,
column: 'amount',
value: 100,
),
PostgresChangeFilter(
type: PostgresChangeFilterType.eq,
column: 'status',
value: 'open',
),
],
callback: (payload) => print(payload))
.subscribe();

Use .and([...]) to combine multiple conditions.

let myChannel = await supabase.channel("db-changes")
let changes = await myChannel.postgresChange(
InsertAction.self,
schema: "public",
table: "orders",
filter: .and([
.gt("amount", value: 100),
.eq("status", value: "open"),
])
)
await myChannel.subscribe()
val myChannel = supabase.channel("db-changes")
val changes = myChannel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {
table = "orders"
filter = "amount=gt.100,status=eq.open"
}
changes
.onEach {
println(it.record)
}
.launchIn(yourCoroutineScope)
myChannel.subscribe()
changes = supabase.channel('db-changes').on_postgres_changes(
"INSERT",
schema="public",
table="orders",
filter="amount=gt.100,status=eq.open",
callback=lambda payload: print(payload)
).subscribe()
var channel = supabase.Realtime.Channel("changes");
channel.Register(new PostgresChangesOptions("public", "orders", ListenType.Inserts, "amount=gt.100,status=eq.open"));
channel.AddPostgresChangeHandler(ListenType.Inserts, (sender, change) =>
{
Console.WriteLine(change.Payload);
});
await channel.Subscribe();

Next steps

To keep going, use these pages: