rykuno
Explore posts from serversDTDrizzle Team
•Created by rykuno on 8/26/2023 in #help
Optional/Default value for Relational `Extras`
I have a couple cases where a default/optional value for "extras" in the relational query builder could come in handy. I only really want to run this if the user is logged in. ATM I have the following solution
If there is no auth user it just sets the user_id to null but its not exactly ideal. Is there any plans or current way to optionally add this statement within the same return block?
9 replies
DTDrizzle Team
•Created by rykuno on 7/2/2023 in #help
PGEnum -> Typescript Enum
Hey there. Is there any convenient way people have found to conveniently turn a pgEnum into a typescript enum such as below? Currently I'm creating DTO's but i figured coupling them would be much easier :). I figure ZOD might come into play but we are utilizing NestJS w/ class-validator atm.
5 replies
DTDrizzle Team
•Created by rykuno on 5/28/2023 in #help
Relation Query - Get likes in post
Playing around with relational queries and I'm not quite getting how I'd retrieve the count of likes on a given post.
I'm able to accomplish this in sql, but I'm having a hard time translating or failing to understand why i cant translate this to drizzle.
7 replies
DTDrizzle Team
•Created by rykuno on 5/13/2023 in #help
Custom `Select` object returns type `any`
Databases like Planetscale do not support FK constraints. As I understand I can manipulate the returned data structure from within the
select
clause.
The data structure returned is correct but there is a typescript error casting it to any. Is there a way to fix this or am I misusing select?
1 replies
TTCTheo's Typesafe Cult
•Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
Trying out the new app directory with an example project and ran into issues with accessing the user session within a server function via
getServerSession
Calling this code from an action
handler within a form yields the following error Method expects to have requestAsyncStorage, none available
.
Is there anyone who has successfully gotten this to work?29 replies
TTCTheo's Typesafe Cult
•Created by rykuno on 1/25/2023 in #questions
Prisma: Asyncronous Extended Fields
Anyone familiar with any better way to accomplish the equivalent of
field resolvers
with prisma?
The Ask
I need an async field returned with each user
The Scenario
Say I want to findMany
on users
but I want a likeCount
and followCount
fields returned with each result.
The expand
api looks to be on the right track but it looks like its unable to perform asynchronous computes for additional fields.
Such as if I wanted to add an async field called likeCount
to user
which would be returned on each user result.
I know I can just _count likes
on user
for this example. This is simplified for an example 1 replies
TTCTheo's Typesafe Cult
•Created by rykuno on 1/17/2023 in #questions
Prisma `clientExtensions` Preview Feature Breaks Types
Enabling the
clientExtensions
preview feature in prisma.schema causes trpc routers to break all typesatefy.
Anyone mess with this yet?4 replies