Filter from array
How can I filter data from my db using arrayContains
Here is my code that I want to be done.
these code gaves me that error.
Here is my code that I want to be done.
const [lengths, profiles] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(users),
searchParams
? db
.select()
.from(users)
.where(
or(
ilike(users.name, `%${searchParams}%`),
ilike(users.location, `%${searchParams}%`),
arrayContains(users.skills, searchParams.split(", ")) // it's not currect
)
)
.limit(itemPerPage)
.offset(offset)
: db
.select()
.from(users)
.orderBy(sql.raw("RANDOM()"))
.limit(itemPerPage)
.offset(offset),
]);const [lengths, profiles] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(users),
searchParams
? db
.select()
.from(users)
.where(
or(
ilike(users.name, `%${searchParams}%`),
ilike(users.location, `%${searchParams}%`),
arrayContains(users.skills, searchParams.split(", ")) // it's not currect
)
)
.limit(itemPerPage)
.offset(offset)
: db
.select()
.from(users)
.orderBy(sql.raw("RANDOM()"))
.limit(itemPerPage)
.offset(offset),
]);these code gaves me that error.

