MasoniteFramework / orm

Masonite ORM is a beautiful Python ORM. It's also a nearly drop in replacement of the Orator ORM
https://orm.masoniteproject.com
MIT License
160 stars 47 forks source link

Feature/find_or #837

Closed JarriqTheTechie closed 7 months ago

JarriqTheTechie commented 1 year ago

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.

JarriqTheTechie commented 1 year ago

@josephmancuso please review.

JarriqTheTechie commented 7 months ago

Test has now been added. @josephmancuso please review.