0.29.0
Added a __visible_fields
filter to PiccoloCRUD
. It's a very powerful feature which lets us specify which fields we want the API to return from a GET request (courtesy @sinisaos).
It can even support joins, but we must supply a max_joins
parameter:
app = PiccoloCRUD(Movie, max_joins=1)
uvicorn(app)
Then we can do:
GET /?__visible_fields=id,name,director.name
Which will return:
{
"rows": [
{
"id": 17,
"name": "The Hobbit: The Battle of the Five Armies",
"director": {
"name": "Peter Jackson"
}
},
...
]
}
By specifying exactly which data we want returned, it is much more efficient, especially when fetching large numbers of rows, or with tables with lots of columns.