Hinky
Hinky
Explore posts from servers
PPrisma
Created by Hinky on 7/5/2024 in #help-and-questions
Argument transaction tx with prisma accerlate typescript error
Yo yo, so i have a very long transaction that i am wanting to break up, just for easier maintance. So i want to pass the transaction func as argument however i am getting typescript type mismatch. ( am guessing because of prisma accerlate) example:
const trans = await prisma.$transaction(async (tx) => {
const isTransaction = await exampleFuncUsingTx(tx);
});


const exampleFuncUsingTx = async (tx: Prisma.TransactionClient) => {
}
const trans = await prisma.$transaction(async (tx) => {
const isTransaction = await exampleFuncUsingTx(tx);
});


const exampleFuncUsingTx = async (tx: Prisma.TransactionClient) => {
}
Doing above, ill get this error:
Argument of type 'Omit<DynamicClientExtensionThis<TypeMap<InternalArgs<{ [x: string]: { [x: string]: unknown; }; }, { [x: string]: { [x: string]: unknown; }; }, { [x: string]: { [x: string]: unknown; }; }, { [x: string]: unknown; }> & { result: {}; model: { $allModels: { ...; }; ... 56 more ...; zzz_invoice: { ...; }; }; query: {}; c...' is not assignable to parameter of type 'TransactionClient'.
The types of 'log.findUnique' are incompatible between these types.
Type '<T_5, A_5>(this: T_5, args: Exact<A_5, Args<T_5, "findUnique"> & PrismaCacheStrategy>) => AcceleratePromise<Result<T_5, A_5, "findUnique"> | null>' is not assignable to type '<T extends logFindUniqueArgs<DefaultArgs>>(args: SelectSubset<T, logFindUniqueArgs<DefaultArgs>>) => Prisma__logClient<...>'.
Types of parameters 'args' and 'args' are incompatible.
Type 'SelectSubset<T, logFindUniqueArgs<DefaultArgs>>' is not assignable to type 'Exact<T, any>'.
Type 'SelectSubset<T, logFindUniqueArgs<DefaultArgs>>' is not assignable to type 'T extends Narrowable ? T : never'.
Argument of type 'Omit<DynamicClientExtensionThis<TypeMap<InternalArgs<{ [x: string]: { [x: string]: unknown; }; }, { [x: string]: { [x: string]: unknown; }; }, { [x: string]: { [x: string]: unknown; }; }, { [x: string]: unknown; }> & { result: {}; model: { $allModels: { ...; }; ... 56 more ...; zzz_invoice: { ...; }; }; query: {}; c...' is not assignable to parameter of type 'TransactionClient'.
The types of 'log.findUnique' are incompatible between these types.
Type '<T_5, A_5>(this: T_5, args: Exact<A_5, Args<T_5, "findUnique"> & PrismaCacheStrategy>) => AcceleratePromise<Result<T_5, A_5, "findUnique"> | null>' is not assignable to type '<T extends logFindUniqueArgs<DefaultArgs>>(args: SelectSubset<T, logFindUniqueArgs<DefaultArgs>>) => Prisma__logClient<...>'.
Types of parameters 'args' and 'args' are incompatible.
Type 'SelectSubset<T, logFindUniqueArgs<DefaultArgs>>' is not assignable to type 'Exact<T, any>'.
Type 'SelectSubset<T, logFindUniqueArgs<DefaultArgs>>' is not assignable to type 'T extends Narrowable ? T : never'.
I suppose my main question, is it safe for me to just make this assumption?
tx: as unknown as Prisma.TransactionClient
tx: as unknown as Prisma.TransactionClient
3 replies
PPrisma
Created by Hinky on 6/11/2024 in #help-and-questions
too many db connections on Prisma Accelerate
No description
16 replies
TTCTheo's Typesafe Cult
Created by Hinky on 1/1/2024 in #questions
typescript trace | autocomplete speed
Hey yall. personally my project autocomplete is painfully slow some times. and im still a noob needing that autocomplete. Anyway ive done a typescript trace and i was curious what others on t3 app look like if anyone is willing to share. Host-spot being on the trpc [trpc]/root - about 700ms. total trace - 13-14 sec, is this similar to what other projects are getting in t3/trpc. mainly to determine if something is wrong in my project or if thisis to be expected my project trace:
2 replies