Is there ideas to support filtering based on relat...
# orm-help
h
Is there ideas to support filtering based on relations in where clause for findUnique?
r
No but you can use
findFirst
for achieving the same.
h
Hmm, and trust the unique fields?
r
Meaning?
h
I mean the row should be unique, but with findFirst, as long as i only filter on actually unique fields it should not be a problem right?
r
Yes that shouldn’t be a problem. Unique or non-unique,
findFirst
will always return a single record if exists.
h
Thx
Also on upsert() is it possible to filter on relations? If i have a relation to user, and a userId i can filter on userId but not on the user table?
r
No
upsert
as of now only checks for unique values in the relation. There’s a request for the same here that you can add a 👍 and follow: https://github.com/prisma/prisma/issues/5436
h
Technically querying user by id instead of userId is still unique. But in the user table not in the table doing upsert on.
r
Yes unique only within the model as of now.
h
Thx
👍 1