Exemplo n.º 1
0
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    nickname = db.Column(db.String(64), unique=True)
    first_name = db.Column(db.String(64))
    last_name = db.Column(db.String(64))
    password = db.Column(db.String(100))
    messages = db.relationship('Message', back_populates='author')
Exemplo n.º 2
0
class Message(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    receiver = db.Column(db.String(60), nullable=False)
    subject = db.Column(db.String(60), nullable=False)
    date_created = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
Exemplo n.º 3
0
class Posts(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), nullable=False)
    content = db.Column(db.String(80), nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) 

    def __repr__(self):
        return f'(' + {self.title} + ', ' + {self.content} + ')'
Exemplo n.º 4
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False)
    password = db.Column(db.String(120),  nullable=False)
    firstname = db.Column(db.String(20), nullable=False)
    lastname = db.Column(db.String(25), nullable=False)
    posts = db.relationship('Posts', backref='author', lazy=True)

    def __repr__(self):
        return f'User {self.id}'
Exemplo n.º 5
0
class Chat(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    chat_name = db.Column(db.String(64))
    created = db.Column(db.DateTime, default=datetime.utcnow)
    chat_users = db.relationship('User',
                                 secondary=chat_users,
                                 lazy='subquery',
                                 backref=db.backref('chats', lazy=True))
Exemplo n.º 6
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(25), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    messages = db.relationship('Message', backref='author', lazy=True)
Exemplo n.º 7
0
class Message(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    author_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    author = db.relationship('User', back_populates="messages")
    chat_id = db.Column(db.Integer, db.ForeignKey('chat.id'), nullable=False)
    text = db.Column(db.String(1000))
Exemplo n.º 8
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
Exemplo n.º 9
0
class Message(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    timestamp = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    content = db.Column(db.String(), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship("User", backref="message")