20 lines
820 B
Python
20 lines
820 B
Python
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Note(Base):
|
|
id = Column(String, primary_key=True, index=True)
|
|
title = Column(String, index=True, nullable=False)
|
|
content = Column(Text, nullable=True)
|
|
is_archived = Column(Boolean, default=False)
|
|
is_pinned = Column(Boolean, default=False)
|
|
user_id = Column(String, ForeignKey("user.id"), nullable=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="notes")
|
|
tags = relationship("Tag", secondary="notetag", back_populates="notes") |