namespace id for chain list
This commit is contained in:
parent
5473be3675
commit
f97fe42f52
|
|
@ -37,9 +37,12 @@ async def chain_upsert_controller(
|
|||
|
||||
|
||||
@router.get("/list")
|
||||
async def chain_list_controller(chain_repository: ChainRepositoryDependency):
|
||||
async def chain_list_controller(
|
||||
namespace_id: str, chain_repository: ChainRepositoryDependency
|
||||
):
|
||||
|
||||
try:
|
||||
chains = await chain_repository.get_list()
|
||||
chains = await chain_repository.get_list(namespace_id=namespace_id)
|
||||
return chains
|
||||
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from loguru import logger
|
|||
|
||||
from uuid import UUID
|
||||
from typing import List
|
||||
from bson import ObjectId
|
||||
from pydantic import TypeAdapter
|
||||
|
||||
from chain_service.database.database import Database
|
||||
|
|
@ -19,9 +20,12 @@ class ChainRepository:
|
|||
await self.collection.replace_one(query, payload, upsert=True)
|
||||
return chain
|
||||
|
||||
async def get_list(self) -> List[Chain]:
|
||||
async def get_list(self, namespace_id: str) -> List[Chain]:
|
||||
# sort_order = ("lastModified", pymongo.DESCENDING)
|
||||
chains = [chain async for chain in self.collection.find()]
|
||||
query = {"namespaceId": namespace_id}
|
||||
chains = [
|
||||
chain async for chain in self.collection.find({"namespaceId": namespace_id})
|
||||
]
|
||||
return TypeAdapter(List[Chain]).validate_python(chains)
|
||||
|
||||
async def get_by_id(self, chain_id: str) -> Chain | None:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user