Add class methods for get by id in models.
This commit is contained in:
parent
af506a3091
commit
4a0e05eae8
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user