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
you need to add a unique constraint @Hycord
what columns are you wanting to use
both name and userId
add a
name is not unique, nor is userId, but they are unique together
@unique([ name,userId ])
ue
ye
dont forget to add a index aswellwhere do I add that?
in the badge table
In schema
which field should be unique
@unique([ name,userId ])
both
togetherboth the name and userId field should have that decorator following their type?
in the badge model
correct?
nah just paste this in lol
@unique( name, userId ])
ahh ok
thankyou
nw
@@unique([name,userId])
@@index([name,userId])
or do I not need that index?ide add an index yeah
your using pscale right?
yeah
ye
Is there anything else obvious that I messed up
no?
pnpm prisma generate
and then restart vsc
oh and push
is it working?About to test
had to completely rewrite a couple functions
hmm
not working at first let me do some debugging
can send the errors here if you want @Hycord
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
lol
The issue here just helped me drastically reduce my idle time waiting for db queries to go through lol
hell yeah!