How do I make the following query in supabase on a stream listening for changes:
select * from public.messages where "to" IS NOT NULL;
From the documentation the closest, I could get was doing the filtering with an "equal to" expression. As captured below:
_messagesStream = supabase
.from('messages:to=eq.123')
.stream(['id'])
.order('created_at')
.execute()
.map((maps) => maps
.map((map) => Message.fromMap(map: map, myUserId: myUserId))
.toList());
But what I need is a query with "IS NOT NULL". A work around I found was to handle complex queries in a view, but the issue here is, I cannot listen for events on view.
Kindly assist.
CodePudding user response:
I think it is not possible. I checked supabase.dart and I can't find any solution on how to implement it.
But you can filter it on your side:
_messagesStream = supabase
.from('messages:to=eq.123')
.stream(['id'])
.order('created_at')
.execute()
.map((maps) => maps
.where((element) => element['to'] != null)
.map((map) => Message.fromMap(map: map, myUserId: myUserId))
.toList());