brestok's picture
init
d0e0a14
raw
history blame contribute delete
857 Bytes
from fastapi_users_db_sqlalchemy import SQLAlchemyBaseUserTable
from sqlalchemy import Column, Integer, String, select
from sqlalchemy.orm import relationship
from project.database import Base
class User(SQLAlchemyBaseUserTable[int], Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True, autoincrement=True)
username = Column(String(128), nullable=False, unique=True)
folders = relationship('Folder', back_populates='owner')
reports = relationship('Report', back_populates='user')
def __str__(self):
return f'{self.email}'
async def get_base_folder(self, session):
from project.bot.models import Folder
folder = await session.execute(select(Folder).where(
Folder.user_id == self.id,
Folder.name == 'Default'
))
return folder.scalars().first()