-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
25 lines (22 loc) · 996 Bytes
/
models.py
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
from sqlalchemy import Column, Integer, String , ForeignKey , DateTime, Boolean, Text
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from database import Base
from datetime import datetime
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, index=True)
fullname = Column(String, index=True)
username = Column(String, index=True , unique=True)
hashed_password = Column(String)
notes = relationship("Note", back_populates="owner")
class Note(Base):
__tablename__ = "notes"
id = Column(Integer, primary_key=True, index=True)
title = Column(String, index=True)
description = Column(Text)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
is_deleted = Column(Boolean , default=False)
owner_id = Column(Integer, ForeignKey("users.id"))
owner = relationship("User", back_populates="notes")