mirror of
https://github.com/StepanovPlaton/torrent_backend.git
synced 2026-04-03 20:30:38 +04:00
Add requirements, cli commands. New project structure
This commit is contained in:
1
database/crud/__init__.py
Normal file
1
database/crud/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .games import *
|
||||
16
database/crud/games.py
Normal file
16
database/crud/games.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.future import select
|
||||
|
||||
from .. import models as mdl
|
||||
from .. import schemas as sch
|
||||
from ..database import add_transaction
|
||||
|
||||
async def add_game(db: AsyncSession, game_info: sch.GameCreate, user_id: int):
|
||||
game = mdl.Game(**game_info.model_dump(), owner_id=user_id)
|
||||
return await add_transaction(db, game)
|
||||
|
||||
async def get_games(db: AsyncSession):
|
||||
return (await db.execute(select(mdl.Game))).scalars().all()
|
||||
|
||||
async def get_game(db: AsyncSession, game_id: int):
|
||||
return await db.get(mdl.Game, game_id)
|
||||
Reference in New Issue
Block a user