New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace findOne
with findUnique
#3697
Comments
findUnique
as an alias to findOne
and deprecate findOne
.findOne
with findUnique
findOne
with findUnique
findOne
with findUnique
findOne
with findUnique
findOne
with findUnique
Personally I have a preference for |
Hey @beeman thanks for sharing your thoughts. I also really like short, concise names. Unfortunately, we've found that newcomers expect |
So, with these changes in place, for queries for unique rows, what's the difference between I ask because if the DB is already enforcing uniqueness, won't the results of There appears to be a difference in the signature for the calls - Ultimately, what I'm trying to understand is: When I'm working with a table that already has my desired unique constraints in place, should I be using |
I would also like some clarification on the purpose/ ideal use case of |
Problem
Today
findOne
depends on the unique constraints of the database to guarantee we'll find 0 or 1 records. According to the documentation:Many people have been confused by this. They expect
findOne
to be more loose. More like: "Find the first record that matches my conditions."Suggested solution
We're adding a new function called
findFirst
to solve for "Find the first record that matches my conditions." Here's the issue: #3676.We're also considering to eventually replace
findOne
withfindUnique
. We feel this is a better name for what this method does.In the short-term, we'd add
findUnique
as an alias tofindOne
and add a deprecation warning tofindOne
. In a later release, we'd removefindOne
.Alternatives
Leave it as is.
🙏 We're very curious to hear your thoughts! Do you see this as a problem like we do?
The text was updated successfully, but these errors were encountered: