Files
core/orm/topic.py

32 lines
1.1 KiB
Python
Raw Normal View History

2021-08-20 11:08:32 +03:00
from datetime import datetime
from sqlalchemy import Column, String, ForeignKey, DateTime, JSON as JSONType
2021-08-20 11:08:32 +03:00
from orm.base import Base
class ShoutTopic(Base):
__tablename__ = 'shout_topic'
2021-10-28 13:42:34 +03: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 13:42:34 +03:00
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
2021-08-20 12:27:19 +03:00
2021-08-20 11:08:32 +03:00
class Topic(Base):
__tablename__ = 'topic'
id = None
slug: str = Column(String, primary_key = True)
2021-10-14 08:28:52 +03: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 13:23:17 +03:00
community = Column(ForeignKey("community.slug"), nullable=False, comment="Community")
2022-07-07 16:55:13 +03:00
oid: str = Column(String, nullable=True, comment="Old ID")
2021-12-12 16:00:38 +03:00