File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -380,8 +380,17 @@ def to_json(self):
380
380
"""
381
381
return json .dumps (self .serialize ())
382
382
383
- def update_or_create (self ):
384
- pass
383
+ @classmethod
384
+ def update_or_create (cls , wheres , updates ):
385
+ self = cls ()
386
+ record = self .where (wheres ).first ()
387
+ total = {}
388
+ total .update (updates )
389
+ total .update (wheres )
390
+ if not record :
391
+ return self .create (total )
392
+
393
+ return self .where (wheres ).update (total )
385
394
386
395
def relations_to_dict (self ):
387
396
"""Converts a models relationships to a dictionary
@@ -422,10 +431,6 @@ def _update_timestamps(self, date=None):
422
431
def _current_timestamp (self ):
423
432
return datetime .now ()
424
433
425
- @staticmethod
426
- def set_connection_resolver (self ):
427
- pass
428
-
429
434
def __getattr__ (self , attribute ):
430
435
"""Magic method that is called when an attribute does not exist on the model.
431
436
You can’t perform that action at this time.
0 commit comments