Prisma Unable To Query Indexed Fields

https://pastes.dev/Eir02TMjVU ^ my whole schema file I've generated and pushed multiple times, but I still can't query on the indexed fields..
pastes | Eir02TMjVU
A paste containing 90 lines of javascript.
26 Replies
Finn
Finn2y ago
you need to add a unique constraint @Hycord what columns are you wanting to use
Hycord | @ When Replying
both name and userId
Finn
Finn2y ago
add a
Hycord | @ When Replying
name is not unique, nor is userId, but they are unique together
Finn
Finn2y ago
@unique([ name,userId ]) ue ye dont forget to add a index aswell
Hycord | @ When Replying
where do I add that?
Finn
Finn2y ago
in the badge table
l
l2y ago
In schema
Hycord | @ When Replying
which field should be unique
Finn
Finn2y ago
@unique([ name,userId ]) both together
Hycord | @ When Replying
both the name and userId field should have that decorator following their type? in the badge model correct?
Finn
Finn2y ago
nah just paste this in lol @unique( name, userId ])
Hycord | @ When Replying
ahh ok thankyou
Finn
Finn2y ago
nw
Hycord | @ When Replying
@@unique([name,userId]) @@index([name,userId]) or do I not need that index?
Finn
Finn2y ago
ide add an index yeah your using pscale right?
Finn
Finn2y ago
ye
Hycord | @ When Replying
Is there anything else obvious that I messed up
Finn
Finn2y ago
no? pnpm prisma generate and then restart vsc oh and push is it working?
Hycord | @ When Replying
About to test had to completely rewrite a couple functions hmm not working at first let me do some debugging
Finn
Finn2y ago
can send the errors here if you want @Hycord
Hycord | @ When Replying
no errors, just my implementation isn't showing me what i need it to LOL I'm just dumb The user wasn't in the database xD either way I needed to figure that out so
Finn
Finn2y ago
lol
Hycord | @ When Replying
The issue here just helped me drastically reduce my idle time waiting for db queries to go through lol
Finn
Finn2y ago
hell yeah!
Want results from more Discord servers?
Add your server