
- Set up project structure with FastAPI - Implement user authentication system with JWT tokens - Create database models for users, notes, and collections - Set up SQLAlchemy ORM and Alembic migrations - Implement CRUD operations for notes and collections - Add filtering and sorting capabilities for notes - Implement health check endpoint - Update project documentation
23 lines
863 B
Python
23 lines
863 B
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
username = Column(String, unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
# Relationships
|
|
notes = relationship("Note", back_populates="owner", cascade="all, delete-orphan")
|
|
collections = relationship("Collection", back_populates="owner", cascade="all, delete-orphan")
|