'QUERY
:param filters:
dict with filters {<col_name>:<value,...}
:param order_column:
name of the column to order
:param order_direction:
the direction to order <\'asc\'|\'desc\'>
:param page:
the current page
:param page_size:
the current page size'

def query(self, filters=None, order_column='', order_direction='', page=None, page_size=None):

    query = self.session.query(self.obj)
    if (len(order_column.split('.')) >= 2):
        tmp_order_column = ''
        for join_relation in order_column.split('.')[:(-1)]:
            model_relation = self.get_related_model(join_relation)
            query = query.join(model_relation)
            tmp_order_column = ((tmp_order_column + model_relation.__tablename__) + '.')
        order_column = (tmp_order_column + order_column.split('.')[(-1)])
    query_count = self.session.query(func.count('*')).select_from(self.obj)
    query_count = self._get_base_query(query=query_count, filters=filters)
    query = self._get_base_query(query=query, filters=filters, order_column=order_column, order_direction=order_direction)
    count = query_count.scalar()
    if page:
        query = query.offset((page * page_size))
    if page_size:
        query = query.limit(page_size)
    return (count, query.all())
