winsoroaks
winsoroaks12mo ago

how do LOWER(q.field("name") LIKE LOWER('%name%')

hi team! tried searching the docs but to no avail. any idea how can i do sth like
.filter((q) => q.eq(q.field("name"), args.name))
.filter((q) => q.eq(q.field("name"), args.name))
but ignoring the case? 😅
3 Replies
jamwt
jamwt12mo ago
since this is just a .filter and not a .withIndex, you can filter in plain ol' JS using a regex etc
winsoroaks
winsoroaksOP12mo ago
thanks, i tried entering the same name but it didnt work for me. am i misunderstanding sth? 🙏
// this didn't work
.filter((q) =>
q.eq(q.field("name"), new RegExp(args.name, "i").toString())
)

// this worked
.filter((q) =>
q.eq(q.field("name"), args.name)
)
// this didn't work
.filter((q) =>
q.eq(q.field("name"), new RegExp(args.name, "i").toString())
)

// this worked
.filter((q) =>
q.eq(q.field("name"), args.name)
)
ballingt
ballingt12mo ago
Jamie is suggesting first collecting the query, then filter the array you get back. So (await ctx.db. ... .collect()).filter(record => record.name.includes(args.name))

Did you find this page helpful?