from demo import db,login_manager
from flask_login import UserMixin
from datetime import datetime

@login_manager.user_loader
def load_user(user_id):
    return User.query.get(int(user_id))

class User(db.Model,UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), unique=True)

    password_hash = db.Column(db.String(128))
    email = db.Column(db.String(64), unique=True)
    date = db.Column(db.DateTime(), default=datetime.now())
    contents = db.relationship('Content', backref='user', lazy='dynamic')
    comments = db.relationship('Comment', backref='user', lazy='dynamic')



