Answer the question
In order to leave comments, you need to log in
Building complex database queries?
Hello! Prompt how to unify the interface of obtaining of the data. Now I have this in my model:
class Ticket(db.Model):
.....
@classmethod
def get_ticket(cls, **kwargs):
return Ticket.query.filter_by(**kwargs).first()
@classmethod
def get_tickets_with_devices(cls, form):
return db.session.query(Ticket).outerjoin(Ticket.device).filter(*form.get_query_args()).\
order_by(Ticket.time_creat.desc())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question