Releases: piccolo-orm/piccolo_api
0.32.0
Added support for the Content-Range HTTP header in the GET endpoint of PiccoloCRUD. This means the API client can fetch the number of available rows, without doing a separate API call to the count endpoint.
GET /?__range_header=true
If the page size is 10, then the response header looks something like:
Content-Range: movie 0-9/100
The feature was created to make Piccolo APIs work better with front ends like React Admin.
Thanks to @trondhindenes for adding this feature, and @sinisaos for help reviewing.
0.31.0
Added hooks to PiccoloCRUD. This allows the user to add their own logic before a save / patch / delete (courtesy @trondhindenes).
For example:
# Normal functions and async functions are supported:
def pre_save_hook(movie):
movie.rating = 90
return movie
PiccoloCRUD(
table=Movie,
read_only=False,
hooks=[
Hook(hook_type=HookType.pre_save, callable=pre_save_hook)
]
)0.30.1
0.30.0
We recently added the __visible_fields GET parameter to PiccoloCRUD, which allows the user to determine which fields are returned by the API.
GET /?__visible_fields=id,name
However, there was no way of the user knowing which fields were supported. This is now possible by visiting the /schema endpoint, which has a visible_fields_options field which lists the columns available on the table and related tables (courtesy @sinisaos).
0.29.2
0.29.1
The __visible_fields filter on PiccoloCRUD now works on the detail endpoint (courtesy @sinisaos). For example:
GET /1/?__visible_fields=id,name,director.name
We also modified a type annotation in FastAPIWrapper, so you can use it with FastAPI's APIRouter without getting a type warning. Thanks to @gmos for reporting this issue.
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.
0.28.1
Fixed a bug with the delete endpoint of PiccoloCRUD. It was returning a 204 response with a body (this isn't allowed, and could cause an exception to be raised in the web server). Thanks to @trondhindenes for reporting this issue.
Updated Swagger UI to the latest version.
0.28.0
Modified the get_ids endpoint of PiccoloCRUD, so it accepts an offset query parameter. It already supported limit.
0.27.0
You can now pass a schema_extra argument to PiccoloCRUD, which is added to the underlying Pydantic schema.
This is mostly to support new Piccolo Admin features.
