Ustice
Ustice
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
I’ll be online in about an hour from now. I accepted your friend request. If you ping me, I can do a screensharing with you if you would like.
19 replies
PPrisma
Created by acidjazz on 8/5/2024 in #help-and-questions
using prisma $extends to add fields to a model, whats the best practice for TS?
That’s what I am saying. You can redefine the types that are generated by Prisma; however, it is possible to extract the types from the Prisma client, and use those instead.
6 replies
PPrisma
Created by acidjazz on 8/5/2024 in #help-and-questions
using prisma $extends to add fields to a model, whats the best practice for TS?
You can read about this in the docs.
6 replies
PPrisma
Created by acidjazz on 8/5/2024 in #help-and-questions
using prisma $extends to add fields to a model, whats the best practice for TS?
You should be able to get the client property on the type returned by a query.
function fetchTokenClient () {
return prisma.token.findFirstOrThrow()
}

type TokenWithClient = Prisma.PromiseReturnType<typeof fetchTokenClient>
function fetchTokenClient () {
return prisma.token.findFirstOrThrow()
}

type TokenWithClient = Prisma.PromiseReturnType<typeof fetchTokenClient>
6 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
@neofrog. Did you get it working?
19 replies
PPrisma
Created by csg242 on 8/9/2024 in #help-and-questions
any fix/status for this bug? https://github.com/prisma/prisma/issues/24475
Links in titles are not clickable
3 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
You’re sending a string instead of number, and that doesn’t work. telegram_id is of type number | bigint | undefined. string is incompatible.
19 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
And it’s possible that they can change as your database evolves. It’s much better to use the generated types, as they will update when you run generate.
19 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
Try not to use manual types for function parameters like you did. It’s too easy to get them wrong.
19 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
No description
19 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
No nothing is wrong. In the type above, you just need to make sure that you’re handling the null case. Make sure that you run prisma generate if you made any scheme changes. I’ll be home this weekend. PM me, and I can do a screen-sharing session to see what is going on first-hand.
19 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
The types are complex. You shouldn’t need to be making any type assertions—they’re dangerous. You’ll so much better to use those dynamic types. The Prisma docs have info on how to work with them.
19 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
Prisma queries don’t really return the model types. Their types are dynamic, based on what you query. Are you not getting correct type inference?
19 replies
PPrisma
Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
Why are you converting telegram_id to a string in your query? That seems unnecessary. Do you still have the type error if you use the direct query, rather than calling getAccount?
19 replies
PPrisma
Created by Matt on 7/31/2024 in #help-and-questions
Using Prisma Client API with NextJS and a Private AWS Database backend
There are two options that I’m aware of: * use prisma introspect to build the prisma/schema.prisma * generate the Prisma schema via script or by hand It doesn’t look like there are existing tools to generate a Prisma schema from liquibase, so you’d be on your own there. Introspection is likely the way I’d go.
4 replies
PPrisma
Created by Up on 6/27/2024 in #help-and-questions
N+1 problem with multiple filter conditions
It might help to include the relevant model info. I’m kind of having a hard to groking what you are trying to do via just the queries.
5 replies