core/orm/topic.py

32 lines
1.1 KiB
Python
Raw Normal View History

2021-08-20 08:08:32 +00:00
from datetime import datetime
from sqlalchemy import Column, String, ForeignKey, DateTime, JSON as JSONType
2022-08-11 05:53:14 +00:00
from base.orm import Base
2021-08-20 08:08:32 +00:00
class ShoutTopic(Base):
__tablename__ = 'shout_topic'
2021-10-28 10:42:34 +00:00
id = None
shout = Column(ForeignKey('shout.slug'), primary_key = True)
topic = Column(ForeignKey('topic.slug'), primary_key = True)
class TopicFollower(Base):
__tablename__ = "topic_followers"
id = None
follower = Column(ForeignKey('user.slug'), primary_key = True)
topic = Column(ForeignKey('topic.slug'), primary_key = True)
2021-10-28 10:42:34 +00:00
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
2021-08-20 09:27:19 +00:00
2021-08-20 08:08:32 +00:00
class Topic(Base):
__tablename__ = 'topic'
id = None
slug: str = Column(String, primary_key = True)
2021-10-14 05:28:52 +00:00
title: str = Column(String, nullable=False, comment="Title")
body: str = Column(String, nullable=True, comment="Body")
pic: str = Column(String, nullable=True, comment="Picture")
children = Column(JSONType, nullable=True, default = [], comment="list of children topics")
2021-12-11 10:23:17 +00:00
community = Column(ForeignKey("community.slug"), nullable=False, comment="Community")
2022-07-07 13:55:13 +00:00
oid: str = Column(String, nullable=True, comment="Old ID")
2021-12-12 13:00:38 +00:00