假设我有一个带popularity
和date_created
字段的User
模型.我想做以下查询:
SELECT * FROM user ORDER BY popularity DESC, date_created DESC LIMIT 10
在SQLAlchemy中,对于单一的一个,这是有效的:
User.query.order_by(User.popularity.desc()).limit(10).all()
我应该再加order_by()
吗?还是把popularity
和date_created
都放进我现在的order_by()
?
我要popularity
优先订购date_created
.