Skip to content

Commit

Permalink
Add helper to reduce base-model boilerplate per #2637
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Oct 24, 2022
1 parent a769b8e commit 868e3e8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions peewee.py
Expand Up @@ -474,6 +474,10 @@ def transaction(self, *args, **kwargs):
return _transaction(self, *args, **kwargs)
def savepoint(self):
return _savepoint(self)
@property
def Model(self):
class Meta: database = self
return type('BaseModel', (Model,), {'Meta': Meta})


class ModelDescriptor(object): pass
Expand Down Expand Up @@ -3449,6 +3453,11 @@ def bind_ctx(self, models, bind_refs=True, bind_backrefs=True):
def get_noop_select(self, ctx):
return ctx.sql(Select().columns(SQL('0')).where(SQL('0')))

@property
def Model(self):
class Meta: database = self
return type('BaseModel', (Model,), {'Meta': Meta})


def __pragma__(name):
def __get__(self):
Expand Down

0 comments on commit 868e3e8

Please sign in to comment.