refactor(database): 优化数据库关联对象的载入 (#10)

This commit is contained in:
MingxuanGame
2025-07-31 20:11:22 +08:00
committed by GitHub
parent 1281e75bb1
commit be401e8885
13 changed files with 73 additions and 166 deletions

View File

@@ -30,11 +30,5 @@ async def get_current_user_by_token(token: str, db: AsyncSession) -> User | None
token_record = await get_token_by_access_token(db, token)
if not token_record:
return None
user = (
await db.exec(
select(User)
.options(*User.all_select_option())
.where(User.id == token_record.user_id)
)
).first()
user = (await db.exec(select(User).where(User.id == token_record.user_id))).first()
return user