Esempio n. 1
0
class Profile(db.Model):
    __tablename__ = 'profiles'

    id = db.Column(db.Integer, primary_key=True)
    avatar = db.Column(db.String(900), nullable=True)
    bio = db.Column(db.String(500), nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    user = db.relationship('User', backref="profiles")
Esempio n. 2
0
class Login(db.Model):
    __tablename__ = 'login'

    id = db.Column(db.Integer, primary_key=True)
    login_name = db.Column(db.String(50), nullable=False)
    password = db.Column(db.String(50), nullable=False)
    users = db.relationship("User", uselist=False, backref="login")
    follow = db.relationship("Followers", uselist=False, backref="login")
Esempio n. 3
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    address = db.Column(db.String(255), nullable=False)
    number = db.Column(db.String(20), nullable=False)
    login_id = db.Column(db.Integer, db.ForeignKey('login.id'), nullable=False)

    profile = db.relationship('Profile', uselist=False, backref="users")
    tweets = db.relationship('Tweet', backref="users")
    follow = db.relationship('Followers', backref="users")
Esempio n. 4
0
class Tweet(db.Model):
    __tablename__ = 'tweets'

    id = db.Column(db.Integer, primary_key=True)
    word = db.Column(db.String(300), nullable=True)
    photo = db.Column(db.String(900), nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)

    user = db.relationship('User', backref=db.backref("users",
                                                      lazy=True))  #add
    reply = db.relationship('Reply', backref="tweet")  # replyを1つだけ表示のため

    #add
    good_count = db.Column(db.Integer, default=0)
    good = False

    Good = db.relationship("Likes", backref="tweets")
Esempio n. 5
0
class Reply(db.Model):
    __tablename__ = 'replys'
    id = db.Column(db.Integer, primary_key=True)
    comment = db.Column(db.String(300), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    tweet_id = db.Column(db.Integer,
                         db.ForeignKey('tweets.id'),
                         nullable=False)
    user = db.relationship('User', uselist=False, backref="replys")
Esempio n. 6
0
class Likes(db.Model):
    __tablename__ = 'likes'

    id = db.Column(db.Integer, primary_key=True)
    color = db.Column(db.String(50), nullable=True)
    tweet_id = db.Column(db.Integer,
                         db.ForeignKey('tweets.id'),
                         nullable=False)
    tweet = db.relationship("Tweet", backref="good")
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)