23 lines
604 B
Python
23 lines
604 B
Python
from sqlalchemy import func
|
|
|
|
from project import db
|
|
|
|
|
|
class User(db.Model):
|
|
|
|
__tablename__ = 'users'
|
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
username = db.Column(db.String, nullable=False)
|
|
email = db.Column(db.String, nullable=False)
|
|
active = db.Column(db.Boolean, default=True, nullable=False)
|
|
created_date = db.Column(db.DateTime, default=func.now(), nullable=False)
|
|
|
|
def to_json(self):
|
|
return {
|
|
'id': self.id,
|
|
'username': self.username,
|
|
'email': self.email,
|
|
'active': self.active,
|
|
}
|