Created
July 12, 2021 10:17
-
-
Save hamaguchi-amago/0950ee0d6e168690dfa913dbed5ef946 to your computer and use it in GitHub Desktop.
【Tortoise ORM】OrderBy昇順・降順
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tortoise import fields, models | |
class TestModel(models.Model): | |
id = fields.IntField(pk=True, null=False) | |
name = fields.CharField(max_length=5, null=False) | |
# 昇順 | |
asc_data = await TestModel.all().order_by("name") | |
# 降順 | |
desc_data = await TestModel.all().order_by("-name") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ブログの記事で作成しました。
興味のある方はご覧ください。
【Tortoise ORM】ソートの昇順・降順
https://neko-py.com/tortoise-orm-sort-asc-desc