Skip to content

Commit

Permalink
add read item api
Browse files Browse the repository at this point in the history
  • Loading branch information
ks6088ts committed Jun 6, 2024
1 parent 5a11135 commit 39fa3b8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions backend/routers/azure_cosmos_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,26 @@ async def create_item(body: azure_cosmos_db_schemas.CreateItemRequest):
database_id=body.database_id,
item=created_item,
)


@router.get(
"/{database_id}/{container_id}/{item_id}",
response_model=azure_cosmos_db_schemas.ReadItemResponse,
status_code=200,
)
async def read_item(
database_id: str,
container_id: str,
item_id: str,
):
container = client.get_container(
database_id=database_id,
container_id=container_id,
)
read_item = client.read_item(
container=container,
item_id=item_id,
)
return azure_cosmos_db_schemas.ReadItemResponse(
item=read_item,
)
4 changes: 4 additions & 0 deletions backend/schemas/azure_cosmos_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ class CreateItemResponse(BaseModel):
container_id: str
database_id: str
item: dict


class ReadItemResponse(BaseModel):
item: dict

0 comments on commit 39fa3b8

Please sign in to comment.