sio-2425/delivery1/server/models/user.py

16 lines
784 B
Python

from sqlalchemy import Integer, String
from sqlalchemy.orm import relationship, Mapped, mapped_column
from database import Base
from dataclasses import dataclass
@dataclass
class User(Base):
__tablename__ = 'users'
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
username: Mapped[str] = mapped_column(String, unique=True, index=True, nullable=False)
full_name: Mapped[str] = mapped_column(String, nullable=False)
email: Mapped[str] = mapped_column(String, unique=True, index=True, nullable=False)
public_key: Mapped[str] = mapped_column(String, nullable=False)
orgs: Mapped[list['Organization']] = relationship('Organization', back_populates='owner')
files: Mapped[list['File']] = relationship('File', back_populates='creator')