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
165 stars 48 forks source link

UpdateOrCreate #817

Closed BSN4 closed 1 year ago

BSN4 commented 1 year ago

Describe the feature as you'd like to see it Some time you want either to update existing raw or create it .. awesome to have UpdateOrCreate

What do we currently have to do now? https://laravel.com/docs/9.x/upgrade#belongs-to-many-first-or-new

Marlysson commented 1 year ago

@josephmancuso @girardinsamuel

There's the model.update_or_create method, but it receives the wheres and the values to update, when replicate the example of link in laravel docs it becomes:

user.related("roles").update_or_create(wheres, updates)

The "wheres" argument, Isn't relation when called, redundant?

BSN4 commented 1 year ago

@Marlysson thanks didn't find it in the docs

BSN4 commented 1 year ago

@Marlysson can it be used outside relations though? like Order.update_or_create({})

josephmancuso commented 1 year ago

@Marlysson can it be used outside relations though? like Order.update_or_create({})

Yes