Get projects by name
This commit is contained in:
parent
c38ddcb01c
commit
aaf3330d22
|
@ -1,6 +1,7 @@
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from typing import Type, TypeVar
|
from typing import Type, TypeVar
|
||||||
from asyncpg.connection import Connection
|
from asyncpg.connection import Connection
|
||||||
|
from asyncpg import Record
|
||||||
|
|
||||||
|
|
||||||
class BaseRepo:
|
class BaseRepo:
|
||||||
|
@ -25,7 +26,7 @@ class UserRepo(BaseRepo):
|
||||||
chat_id,
|
chat_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get(self, user_id: int):
|
async def get(self, user_id: int) -> Record:
|
||||||
return await self.conn.fetchval(
|
return await self.conn.fetchval(
|
||||||
"SELECT user_id FROM users WHERE user_id = $1", user_id
|
"SELECT user_id FROM users WHERE user_id = $1", user_id
|
||||||
)
|
)
|
||||||
|
@ -41,7 +42,8 @@ class ProjectRepo(BaseRepo):
|
||||||
user_id, *args
|
user_id, *args
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get(self, user_id: int):
|
async def get(self, name: str) -> Record:
|
||||||
return await self.conn.fetchval(
|
return await self.conn.fetch(
|
||||||
"SELECT name, description FROM projects WHERE creator = $1", user_id
|
"SELECT id, name, description FROM projects WHERE name LIKE $1",
|
||||||
|
f"%{name}%"
|
||||||
)
|
)
|
||||||
|
|
Reference in a new issue