from config import db
from uuid import uuid4

class Contact(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(80), unique=False, nullable=False)
    last_name = db.Column(db.String(80), unique=False, nullable=False)
    email = db.Column(db.String(120), unique=False, nullable=False)
    
    def to_json(self):
        return {
            "id": self.id,
            "firstName":self.first_name,
            "lastName":self.last_name,
            "email": self.email,
        }  
        
        
def get_uuid():
    return uuid4().hex

class User(db.Model):
    __tablename__ = "users"
    id = db.Column(db.String(32), primary_key=True, unique=True, default=get_uuid)
    email = db.Column(db.String(345), unique=True)
    password = db.Column(db.Text, nullable=False)

class Orders(db.Model):
    __tablename__ ="orders"
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120), unique=False, nullable=False)
    order = db.Column(db.String(345), unique=False, nullable=False)
    def to_json(self):
        return {
            "id": self.id,
            "email":self.email,
            "order":self.order,
        }  
    
    
# class Category(db.Model):
#     __tablename__ = "categories"
#     id = db.Column(db.String(32), primary_key=True, unique=True, default=get_uuid)
#     name = db.Column(db.String(345), default='New Shirt')
#     number = db.Column(db.Integer)
#     sale = db.Column(db.Boolean, default=False)
    