kotlinsupabase

Koltlin: How to use filter eq to do the filter with more than 1 conditions


Currently, I am using

     val response = supabase.from("schedules")
                    .select()
                    { filter {eq("user_id", userId)   } }  // Filtering by the user_id

to filter by the uder_id. However, I also want to filter by defualt (which is a bool value) after this. I cannot find any documentation about that. Can someone give me some suggestions?

I have tried things like

val response = supabase.from("schedules")
                    .select()
                    { filter {eq("user_id", userId),eq("defualt", "TRUE")   } }

and

val response = supabase.from("schedules")
                    .select()
                    { filter {eq("user_id", userId) } }.select()
                    { filter {eq("defualt", "TRUE")   } }

but none of them work. I cannot find any documentation about that. Can someone give me some suggestions?


Solution

  • You have to use and or or functions when want to have multiple conditions. For example:

    val response = supabase.from("schedules").select { 
      filter {
        and {
          eq("user_id", userId)
          eq("default", true)
        }
      }
    }