Implementing D1 batching (getting typed queries as input and returning typed InferResult)
Hi. I've wanted to get D1 batching to work, so I've tried doing as below. Functionally the code works, however I would like to get the proper type safety for this. Essentially I extend Kysely to add the
executeBatch
method and I want to infer the results for each of the individual queries. Is this possible?3 Replies
https://pastecord.com/fazekabave.ts
the executeBatch method gets the compiled queries and the intention it returns an array of queryresponses
like is this possible
like the easiest way from a type perspective is probably getting compiledquery inputs and not returning anything (not ideal tho)
per se i think i'm really asking for a way to represent an array of queries with type safety, since i can get the result type with
InferResult<Query>
Unknown User•6d ago
Message Not Public
Sign In & Join Server To View
like 10-20 on average maybe? i have instances where i also run say ~3k queries at once. defo could be optimized into say inserting more values (one case) but then sqlite limit of 1k variables throttles it quite a bit, and then update queries can't really be grouped (besides adding a CTE or a temp table or something)