Add class methods for get by id in models.

This commit is contained in:
Alexis Lahouze 2015-06-11 23:30:20 +02:00
parent af506a3091
commit 4a0e05eae8
4 changed files with 16 additions and 0 deletions

View File

@ -44,3 +44,7 @@ class Account(db.Model):
).outerjoin(Entry).group_by(cls.id).order_by(cls.id)
return query
@classmethod
def get(cls, session, id):
return session.query(cls).filter(cls.id == id).one()

View File

@ -62,3 +62,7 @@ class Entry(db.Model):
).filter(cls.account_id == account_id).order_by("year", "month")
return query
@classmethod
def get(cls, session, id):
return session.query(cls).filter(cls.id == id).one()

View File

@ -95,3 +95,7 @@ class Operation(db.Model):
).group_by(cls.account_id)
return query
@classmethod
def get(cls, session, id):
return session.query(cls).filter(cls.id == id).one()

View File

@ -67,3 +67,7 @@ class ScheduledOperation(db.Model):
)
return query
@classmethod
def get(cls, session, id):
return session.query(cls).filter(cls.id == id).one()