Prisma1: Single queries should be more powerful

Created on 7 Mar 2019  路  2Comments  路  Source: prisma/prisma1

Is your feature request related to a problem? Please describe.
Currently, single queries like .user can only query by unique fields:

selection_999 1089

Describe the solution you'd like
I want to query by everything, not just unique IDs, just like I can do when querying multiple users:

selection_999 1096

kinquestion arenext

All 2 comments

Hi @steebchen

I think it really doesn't make any sense to add non-unique value to a single query(any field annotated with @unique is available even if it is a relation).

Like if the field is non-unique there is absolutely a chance that we will get more than one match. That is why other non-unique fields are available via another method that will return an array. You can grab the first result if you are sure that one only such entity exist. In the upcoming API there will be findOne option that will do this for you.

Makes sense. To rephrase, I was rather asking for a findOne method to only return a single result (not guaranteed by SQL, but guaranteed by my schema).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thomaswright picture thomaswright  路  3Comments

marktani picture marktani  路  3Comments

ragnorc picture ragnorc  路  3Comments

dohomi picture dohomi  路  3Comments

Fi1osof picture Fi1osof  路  3Comments