コード例 #1
0
class User(db.Model):
    __tablename__ = 'users'
    __bind_key__ = 'sitedata'
    id = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
    email = db.Column(db.String, nullable=False)
    username = db.Column(db.String, nullable=False)
    avatar = db.Column(db.String, nullable=False)
    password = db.Column(db.String, nullable=False)
    tokenVersion = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    createdAt = db.Column(db.DateTime, nullable=False)
コード例 #2
0
class Meme(db.Model):
    __tablename__ = 'memes'
    __bind_key__ = 'sitedata'
    id = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
    url = db.Column(db.String, nullable=False)
    userId = db.Column(db.ForeignKey('users.id'), nullable=False)
    createdAt = db.Column(db.DateTime, nullable=False)
    user = db.relationship('User', primaryjoin='Meme.userId == User.id', backref='memes')
コード例 #3
0
class CommentVote(db.Model):
    __tablename__ = 'comment_vote'
    __bind_key__ = 'sitedata'
    id = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
    userId = db.Column(db.ForeignKey('users.id'), nullable=False)
    commentId = db.Column(db.ForeignKey('comments.id'), nullable=False)
    value = db.Column(db.Integer, nullable=False)
    createdAt = db.Column(db.DateTime, nullable=False)
    comment = db.relationship('Comment', primaryjoin='CommentVote.commentId == Comment.id', backref='comment_votes')
    user = db.relationship('User', primaryjoin='CommentVote.userId == User.id', backref='comment_votes')