Dynamic Batch w/Turso

I am creating an array of queries by using .map(). However TS + Drizzle is not happy with this when using it with .batch(). Has anybody found a workaround for this? Using v0.29.3. The queries are valid SQL queries. I'm currently using the Turso Client on it's own to accomplish this.
No description
2 Replies
albyzyx
albyzyx9mo ago
Hey did you find a solution for this?
The Safe Fire!
The Safe Fire!9mo ago
i am not sure about this specific issue, but you can insert list of values in a single insert query (which you dont need the batch here) for example:
await drizzleClient.insert(favourites).values(["1","2"].map((n) => ({ advertiserId: n }))
// or
await drizzleClient.insert(favourites).values([{ advertiserId: "1" }, { advertiserId: "2" }])
await drizzleClient.insert(favourites).values(["1","2"].map((n) => ({ advertiserId: n }))
// or
await drizzleClient.insert(favourites).values([{ advertiserId: "1" }, { advertiserId: "2" }])
Want results from more Discord servers?
Add your server