Skip to content
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

Add get_or_none method #22

Closed
mojixcoder opened this issue Dec 25, 2021 · 3 comments
Closed

Add get_or_none method #22

mojixcoder opened this issue Dec 25, 2021 · 3 comments

Comments

@mojixcoder
Copy link

Hey, I'm planing to add get_or_none method to the Queryset class.
Since most of the python ORMs have implemented this method, I think it's nice for us to have it too.
What is your opinion?

@aminalaee
Copy link
Owner

Hey,

Thanks for the feedback.
We actually have that I think,

Model.query.first() will return first or None.
But Model.query().get() will get first or throw exceptions.

Does that make sense?

If you think it's not clear in the docs, we can improve that.

@mojixcoder
Copy link
Author

I didn't know 'first' does that, so we don't need to do that.
Thank you

@aminalaee
Copy link
Owner

No worries.

Although I think we could have other shodtcuts like get_or_create or update_or_create.
They can be useful. If you feel like they're usable feel free to do them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants