Filter from JSON with CS (contains)
I'm trying to make a small search system for my website, where it would search in some columns depending on a choice.
For example, the search can have this as parameters: search: [{f: 'titre', q: 'ilike'}, {f:'categories', q: 'contains'}],
So, with that I would like to generate a OR() query to search in every column (f) with the specified method (q),
For testing, I have a function like that in my code:
type.search.forEach((f, i) => {
if(i>0) rep += ','
if(f.q === 'ilike') rep += f.f + '.ilike.' + searchString + ''
if(f.q === 'contains') rep += f.f + ".cs.{"+ searchString + "}"
})
And this would output titre.ilike.inf,categories.cs.{inf} for example
The problem is, when I use this output in .or() of my supabase query, I always have error with the CS (bas query token...) So, I don't get how I'm suppose to make it work. Categories is an array in that case
For example, the search can have this as parameters: search: [{f: 'titre', q: 'ilike'}, {f:'categories', q: 'contains'}],
So, with that I would like to generate a OR() query to search in every column (f) with the specified method (q),
For testing, I have a function like that in my code:
type.search.forEach((f, i) => {
if(i>0) rep += ','
if(f.q === 'ilike') rep += f.f + '.ilike.' + searchString + ''
if(f.q === 'contains') rep += f.f + ".cs.{"+ searchString + "}"
})
And this would output titre.ilike.inf,categories.cs.{inf} for example
The problem is, when I use this output in .or() of my supabase query, I always have error with the CS (bas query token...) So, I don't get how I'm suppose to make it work. Categories is an array in that case