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

Feature/find_or #837

Merged

Conversation

JarriqTheTechie
Copy link
Contributor

Retrieves record by primary key. If no record exists matching the given criteria, a user-defined callback function will be executed.

eg.

id: int = 1024
callback: Callable = lambda a, b : a * b
arguments: tuple = (5, 6)

User.find_or(id, callback, arguments)

The callback will run only if user with id 1024 is not found. Arguments to the callback are passed in as tuples.

…en criteria, a user-defined callback function will be executed.
…en criteria, a user-defined callback function will be executed.
@JarriqTheTechie
Copy link
Contributor Author

@josephmancuso please review.

Copy link
Member

@josephmancuso josephmancuso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a test

@JarriqTheTechie
Copy link
Contributor Author

Test has now been added. @josephmancuso please review.

Copy link
Member

@josephmancuso josephmancuso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code review looks good

@josephmancuso josephmancuso merged commit 74355a3 into MasoniteFramework:2.0 Dec 6, 2023
4 of 5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants