ぼざろクリーチャーシリーズ DB 兼 API(自分用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

21 lines
465 B

  1. import eloquent
  2. class DatabaseManager (eloquent.DatabaseManager):
  3. pass
  4. class Model (eloquent.Model):
  5. def upsert (
  6. self,
  7. *args: str,
  8. ) -> None:
  9. q = self.query ()
  10. for arg in args:
  11. q = q.where (arg, getattr (self, arg))
  12. row = q.first ()
  13. if row is not None:
  14. self.id = row.id
  15. self._Model__exists = True # pylint: disable = protected-access
  16. self.save ()