PsycologyAPI/models/category.py

17 lines
565 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
# @Time : 2024/11/14 下午4:04
# @Author : 河瞬
# @FileName: category.py
# @Software: PyCharm
from tortoise.models import Model
from tortoise import fields
class Category(Model):
id = fields.IntField(primary_key=True)
name = fields.TextField()
description = fields.TextField()
# 这个类别是有分层类似树状结构的所以需要一个field来表示父类和子类
parent = fields.ForeignKeyField("models.Category", related_name="children", null=True)
children = fields.ReverseRelation["Category"]