I have a router that fetches all data from the database. Here is my code:
@router.get('/articles/', response_model=List[articles_schema.Articles])
async def main_endpoint():
query = articles_model.articles.select().where(articles_model.articles.c.status == 2)
return await db.database.fetch_all(query)
The response is an array that contains JSON objects like this
[
{
"title": "example1",
"content": "example_content1"
},
{
"title": "example2",
"content": "example_content2"
},
]
But I want to make the response like this:
{
"items": [
{
"title": "example1",
"content": "example_content1"
},
{
"title": "example2",
"content": "example_content2"
},
]
}
How can I achieve that? Please help. Thank you in advance