text: #!/usr/bin/env python
  # -*- encoding: utf-8 -*-
  """
  @Author  :   王超逸
  @File    :   model.py
  @Time    :   2021/2/22 10:16
  @Desc    :
  """
  import asyncio
  
  from tortoise import fields, Tortoise, run_async
  from tortoise.models import Model
  
  
  class Tournament(Model):
      # Defining `id` field is optional, it will be defined automatically
      # if you haven't done it yourself
      id = fields.IntField(pk=True)
      name = fields.CharField(max_length=255)
  
      # Defining ``__str__`` is also optional, but gives you pretty
      # represent of model in debugger and interpreter
      def __str__(self):
          return self.name
  
  
  class Event(Model):
      id = fields.IntField(pk=True)
      name = fields.CharField(max_length=255)
      # References to other models are defined in format
      # "{app_name}.{model_name}" - where {app_name} is defined in tortoise config
      tournament = fields.ForeignKeyField('models.Tournament', related_name='events')
      participants = fields.ManyToManyField('models.Team', related_name='events', through='event_team')
  
      def __str__(self):
          return self.name
  
  
  class Team(Model):
      id = fields.IntField(pk=True)
      name = fields.CharField(max_length=255)
  
      def __str__(self):
          return self.name
  
  
  
  
  
  
  