K
Join ServerKysely
help
createQueryId
Is this function supposed to be exported and used in users code? I'm handling query execution with a custom executor and the
I'm asking cause the default import is set to:
executeQuery
method asks me for a QueryId
. Am I supposed to use kysely internal implementation or am I free to use a custom one? It's just a random string I see, but does it involve something else internally?I'm asking cause the default import is set to:
import { createQueryId } from "kysely/dist/cjs/util/query-id"
Having a custom executor is not something I thought people could do and it's not officially supported. That's the reason why
createQueryId
is not public.I didn't think people would ever need to create their own query ids
Ok so thatโs not thought of being public. Itโs ok, it was just to double check I was doing everything fine (or wrong ๐
)
My use case, if that could help, is using kysely with https://github.com/Effect-TS/effect effect system. So I need to separate query building from query execution, to better compose functions (effects)
Basically Iโm separating the kysely instance from the kysely query executor you get from retrieving
getExecutor
and then I use the first for build Compilable
queries and I use the separated query executor to execute those. So I need a queryIdAre there some technical reasons to choose a specific implementation for the createQueryId or I can just use whatever random string I want?
Hey ๐
Sounds like you're trying to pull off things done in this [recipe](https://github.com/koskimas/kysely/blob/master/recipes/splitting-build-compile-and-execute-code.md)
You should be able to pass a uuid
Sounds like you're trying to pull off things done in this [recipe](https://github.com/koskimas/kysely/blob/master/recipes/splitting-build-compile-and-execute-code.md)
You should be able to pass a uuid
Thanks! I'm doing something similar, just wanted to be sure I could use whatever
queryId
I wanted as long as it's unique (I guess) as when using UUIDsOn top of such recipe, there's no way to "omit" the execution bit from the query builder right? So for example if I'm mistaken and use the dummy kysely instance to do an execute and not just compile I get a runtime error without prior warning, right?
On top of such recipe, there's no way to "omit" the execution bit from the query builder right? So for example if I'm mistaken and use the dummy kysely instance to do an execute and not just compile I get a runtime error without prior warning, right?
According to the recipe:
Trying to execute queries using "cold" kysely instances will return empty results without communicating with a database.
Yes, but that doesn't prevent me or someone else from using kysely to generate promises which will never get correctly executed at runtime, while being correct at compile-time.
My use case is the one where I create a kysely instance, get the executor from it and wrap it with a function "execute" so that it run the promise with a
I then proceed to use the kysely instance as a query builder. It would be nice to evict all the "execution" capabilities from it in order to make it typed as it was only a query builder.
My use case is the one where I create a kysely instance, get the executor from it and wrap it with a function "execute" so that it run the promise with a
Compilable
, catch the result and return a Result | Error
basically, so that it never "crash/throw".I then proceed to use the kysely instance as a query builder. It would be nice to evict all the "execution" capabilities from it in order to make it typed as it was only a query builder.
so that I'm forced to use my
execute
function which has the kysely executor inside, everytime I need to execute something created by the kysely query builder2 Messages Not Public
Sign In & Join Server To View
I was asking if it was feasible at all to completely separate the query building capabilities from the exection features. I guess that's dialect agnostic too (it would be more, nonetheless)
Message Not Public
Sign In & Join Server To View
It's a type thing at the end, removing
.execute
methods from query buildersI assume it's not so easy now with a lot of types ๐
Message Not Public
Sign In & Join Server To View