core/orm/comment.py

30 lines
1.3 KiB
Python
Raw Normal View History

2021-09-03 16:01:31 +00:00
from typing import List
from datetime import datetime
2021-10-12 19:38:12 +00:00
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean
2021-09-05 08:56:15 +00:00
from sqlalchemy.orm import relationship
2021-09-03 16:01:31 +00:00
from orm.base import Base
class CommentRating(Base):
__tablename__ = "comment_rating"
id = None
comment_id = Column(ForeignKey('comment.id'), primary_key = True)
createdBy = Column(ForeignKey('user.slug'), primary_key = True)
2021-10-13 17:46:30 +00:00
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Timestamp")
2021-09-03 16:01:31 +00:00
value = Column(Integer)
class Comment(Base):
2021-09-05 08:56:15 +00:00
__tablename__ = 'comment'
2021-10-12 19:38:12 +00:00
body: str = Column(String, nullable=False, comment="Comment Body")
2021-09-05 08:56:15 +00:00
createdAt = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
2022-07-07 13:55:13 +00:00
createdBy: str = Column(ForeignKey("user.slug"), nullable=False, comment="Sender")
2021-09-05 08:56:15 +00:00
updatedAt = Column(DateTime, nullable=True, comment="Updated at")
2022-07-07 13:55:13 +00:00
updatedBy = Column(ForeignKey("user.slug"), nullable=True, comment="Last Editor")
2021-09-05 08:56:15 +00:00
deletedAt = Column(DateTime, nullable=True, comment="Deleted at")
2022-07-07 13:55:13 +00:00
deletedBy = Column(ForeignKey("user.slug"), nullable=True, comment="Deleted by")
2022-01-28 09:49:46 +00:00
shout = Column(ForeignKey("shout.slug"), nullable=False)
2021-11-21 11:04:38 +00:00
replyTo: int = Column(ForeignKey("comment.id"), nullable=True, comment="comment ID")
2021-09-03 16:01:31 +00:00
ratings = relationship(CommentRating, foreign_keys=CommentRating.comment_id)
2022-07-07 13:55:13 +00:00
oid: str = Column(String, nullable=True)