© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
2 replies
Beteer

checking if value in column (defined as array) contains given substring

i have users table with column id, name, skills (defined as array).
for example
{
  "id" : 1,
  "name" : "John",
  "skills" : ["JavaScript", "Java", "Pascal", "C++"]
},
{
  "id" : 2,
  "name" : "Michael",
  "skills" : ["JavaScript", "Pascal", "C++"]
}
{
  "id" : 1,
  "name" : "John",
  "skills" : ["JavaScript", "Java", "Pascal", "C++"]
},
{
  "id" : 2,
  "name" : "Michael",
  "skills" : ["JavaScript", "Pascal", "C++"]
}

but when i type "Java" it only returns row with id = 1, i want it also to return the second row, because the word "JavaScript" also contains "java". Here's the model i made.

getAllUsers: (objParams) =>
    new Promise((resolve, reject) => {
      let query = supabase.from("user").select("*");

      if (objParams.search.length > 0) {
        query = query.contains("skill", objParams.search);
      }

      query
        .order(objParams.column, { ascending: objParams.order })
        .range(objParams.offset, objParams.offset + objParams.limit - 1)
        .then((result) => {
          if (!result.error) {
            resolve(result);
          } else {
            reject(result);
          }
        });
    }),
getAllUsers: (objParams) =>
    new Promise((resolve, reject) => {
      let query = supabase.from("user").select("*");

      if (objParams.search.length > 0) {
        query = query.contains("skill", objParams.search);
      }

      query
        .order(objParams.column, { ascending: objParams.order })
        .range(objParams.offset, objParams.offset + objParams.limit - 1)
        .then((result) => {
          if (!result.error) {
            resolve(result);
          } else {
            reject(result);
          }
        });
    }),


objParams
objParams
is an object contains some values for filtering:
page
page
,
limit
limit
,
search
search
for keyword to search,
order
order
type (asc or desc).

if it was just a text i usually use
ilike
ilike
for that. for an array is there any possible ways to achieve that using .contains() ?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to check if a column contains a given string (exactly)
SupabaseSSupabase / help-and-questions
4y ago
REST URL Filter: Column contains value
SupabaseSSupabase / help-and-questions
3y ago
Filter for 'contains any' for an array column, searching by an array
SupabaseSSupabase / help-and-questions
4y ago
RLS policy for insert to check given column value?
SupabaseSSupabase / help-and-questions
4y ago