core/orm/topic.py

34 lines
1.2 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
2022-09-03 10:50:14 +00:00
class ShoutTopic(Base):
2022-09-03 10:50:14 +00:00
__tablename__ = "shout_topic"
id = None # type: ignore
shout = Column(ForeignKey("shout.slug"), primary_key=True)
topic = Column(ForeignKey("topic.slug"), primary_key=True)
class TopicFollower(Base):
2022-09-03 10:50:14 +00:00
__tablename__ = "topic_followers"
2021-08-20 09:27:19 +00:00
2022-09-03 10:50:14 +00:00
id = None # type: ignore
follower = Column(ForeignKey("user.slug"), primary_key=True)
topic = Column(ForeignKey("topic.slug"), primary_key=True)
createdAt = Column(DateTime, nullable=False, default=datetime.now, comment="Created at")
2021-08-20 08:08:32 +00:00
2022-09-03 10:50:14 +00:00
class Topic(Base):
__tablename__ = "topic"
2021-12-12 13:00:38 +00:00
2022-09-03 10:50:14 +00:00
id = None # type: ignore
slug = Column(String, primary_key=True)
title = Column(String, nullable=False, comment="Title")
body = Column(String, nullable=True, comment="Body")
pic = Column(String, nullable=True, comment="Picture")
children = Column(JSONType, nullable=True, default=[], comment="list of children topics")
community = Column(ForeignKey("community.slug"), nullable=False, comment="Community")
oid = Column(String, nullable=True, comment="Old ID")