-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
28 lines (19 loc) · 762 Bytes
/
models.py
File metadata and controls
28 lines (19 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import datetime
from sqlalchemy import Column, String, Integer, Boolean, DateTime, ForeignKey
from .database import Base
from sqlalchemy.orm import relationship
class ToDo(Base):
__tablename__ = "todos"
id = Column(Integer, primary_key=True, index=True)
task = Column(String)
done = Column(Boolean, default=False)
due = Column(DateTime, default=datetime.datetime.utcnow)
user_id = Column(Integer, ForeignKey("users.id"))
owner = relationship("User", back_populates="todos")
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, index=True)
name = Column(String)
email = Column(String)
password = Column(String)
todos = relationship('ToDo', back_populates="owner")