PsycologyAPI/models/category.py

17 lines
565 B
Python
Raw Normal View History

2024-11-29 08:09:42 +00:00
# -*- 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"]