app.utils.request_query_operator.Helper.build_order_by
- static Helper.build_order_by(db_model: Type[peewee.Model], request_data: dict) list
Build sorting fields with zero or more Column-like objects to order by.
Example
Peewee query: User.select().order_by(User.created_at.asc())
Request fields: >>> from app.models.user import User >>> db_model = User >>> request_data = {‘order’: [{‘sorting’: ‘asc’, ‘field_name’: ‘created_at’}]} >>> Helper.build_order_by(db_model, request_data) [<peewee.Ordering object at …>]
Notes
Actually is not posible to order across joins.
References
http://docs.peewee-orm.com/en/latest/peewee/querying.html#sorting-records http://docs.peewee-orm.com/en/latest/peewee/api.html#Query.order_by