Moved API code to different directory
This commit is contained in:
32
api/models.py
Normal file
32
api/models.py
Normal file
@ -0,0 +1,32 @@
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
||||
|
||||
|
||||
class User(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
username = db.Column(db.String(20), unique=True, nullable=False)
|
||||
email = db.Column(db.String(120), unique=True, nullable=False)
|
||||
password = db.Column(db.String(60), nullable=False)
|
||||
# is_superuser = db.Column(db.Boolean, default=False)
|
||||
|
||||
def to_dict(self):
|
||||
return {"id": self.id, "username": self.username}
|
||||
|
||||
class Task(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
title = db.Column(db.String(100), nullable=False)
|
||||
description = db.Column(db.Text)
|
||||
done = db.Column(db.Boolean, default=False)
|
||||
due_date = db.Column(db.Date)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"title": self.title,
|
||||
"description": self.description,
|
||||
"due_date": self.due_date,
|
||||
"done": self.done,
|
||||
"user_id": self.user_id
|
||||
}
|
Reference in New Issue
Block a user