from . import db
from flask_login import UserMixin #only use for login user
from sqlalchemy.sql import func

class GlobalNote(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    data = db.Column(db.String(10000))
    date = db.Column(db.DateTime(timezone=True), default=func.now())
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

class Note(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    data = db.Column(db.String(10000))
    date = db.Column(db.DateTime(timezone=True), default=func.now())
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

class User(db.Model, UserMixin):
    # define a layout for the object
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(150), unique=True) #max length = 150
    password = db.Column(db.String(150))
    first_name = db.Column(db.String(150))
    notes = db.relationship('Note')
    globalnotes = db.relationship('GlobalNote')