Help with 'in' queries

Hi - sorry if this has been asked, but it's kind of hard to search for! If it helps, I'm using cloudflare's D1 database (sqlite). What I'd like to do is the following query: select id, tag from tags where tag in ('foo', 'bar', 'baz'); The closest I can get so far is: const tagsAlreadyThere = await getEntriesDb(context).run( Select Id, Tag from LFLGTags where Tag in (${tags.map((t) => '${t}').join(', ')}) ) But that fails if a tag has a single quote in it... I'd like to do something like a prepare statement, but I haven't been able to figure out how to do that in this case. If there's a better way to do such a query I'd be glad to find it... the nice thing about it is it's a single query, rather than querying for each tag individually. Thanks!
1 Reply
chris_st
chris_stOP2mo ago
For anyone else who finds this, trying to deal with this, evidently the inArray operator allows this type of query: https://orm.drizzle.team/docs/operators#inarray
Drizzle ORM - Filters
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Want results from more Discord servers?
Add your server