diff options
Diffstat (limited to 'database.py')
| -rw-r--r-- | database.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/database.py b/database.py index 2559b0f..746078e 100644 --- a/database.py +++ b/database.py @@ -142,6 +142,24 @@ class Vote(Base): "impact" : self.impact } +class CommentVote(Base): + __tablename__ = "commentvotes" + id = db.Column(Types.ObjectId, primary_key=True, default=ObjectId) + author_id = db.Column(Types.ObjectId, db.ForeignKey("users.id")) + comment_id = db.Column(Types.ObjectId, db.ForeignKey("comments.id")) + impact = db.Column(db.Integer, nullable=False) + + author = relationship("User") + comment = relationship("Comment") + + def json(self): + return { + "id" : self.id, + "author" : self.author.json(), + "comment" : self.comment.id, + "impact" : self.impact + } + #class Dependency(Base): #__tablename__ = "dependencies" #id = db.Column(db.Integer, primary_key=True, default=ObjectId) |
