Would want to query: lte('dateOut', '2021-01-31') ...
# help
r
Would want to query: lte('dateOut', '2021-01-31') .gte('dateOut', '2021-01-01') OR .is('dateOut', null) Need help on that please
t
@User you should be able to do this with the or function:
Copy code
const { data, error } = await supabase
  .from('cities')
  .select('name, country_id')
  .or('dateOut.lte.2021-01-31,dateOut.gte.2021-01-01,dateOut.is.null')
r
@User Thanks but it's not filtering as described. - If
dateOut
has a date within range 2021-01-01 - 2021-01-31 = list it - If
dateOut
is null = list it I can do 2 queries for it but thought I'd combine them which seems difficult. Query 1
Copy code
.gte('dateOut', '2021-01-01')
.lte('dateOut', '2021-01-31')
Query 2
.is('dateOut', null)
Using the combined OR query lists records with
dateOut
prior to 2021-01-01 as it's actually earlier than the parameter 2021-01-31
I also tried with doing a and() inside the OR with no success
Example from the documentation:
Copy code
const { data, error } = await supabase
  .from('cities')
  .select('name, country_id')
  .or('id.gt.20,and(name.eq.New Zealand,name.eq.France)')
where I played around with having
.or('dateOut.lte.2021-01-31,dateOut.is.null,and(dateOut.gte.2021-01-01)')
It always gives me the record with
dateOut: '2020-12-15',
Would really appreciate some guidance here. I have more examples where an ‘eq’ on a relational bring back all results but null on the records that shouldn’t qualify. Is there an issue with the filters? I’m used to Graphql or sql and the node seems to not work as expected.