コード例 #1
0
class Course(db.Model, Base):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.Text, nullable=False)
    price = db.Column(db.Integer)
    Category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
コード例 #2
0
class Follow(db.Model):
    """Association Table between the users and channels"""
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)
    chan_id = db.Column(db.Integer,
                        db.ForeignKey('channel.id'),
                        primary_key=True)

    channel = db.relationship("Channel", back_populates="followers")
    user = db.relationship("User", back_populates="following")
コード例 #3
0
class Post(db.Model):
    """Association Table between User and Channel"""
    id = db.Column(db.Integer, primary_key=True)
    chan_id = db.Column(db.Integer, db.ForeignKey('channel.id'))
    user_name = db.Column(db.String(20), nullable=False)
    text = db.Column(db.Text, nullable=False)
    timestamp = db.Column(db.DateTime, default=datetime.utcnow)

    channel = db.relationship("Channel", back_populates="posts")
コード例 #4
0
class Category(db.Model, Base):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    courses = db.relationship('Course', backref='category', lazy=True)
コード例 #5
0
class OAuth (db.Model, OAuthConsumerMixin, Base):
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    courses = db.relationship(User)