added ?fields query parameter support to limit the returned api fields

This commit is contained in:
Gani Georgiev
2023-04-25 17:58:51 +03:00
parent 841a4b6913
commit c0a7d0f6c0
5 changed files with 334 additions and 1 deletions
+11
View File
@@ -1,5 +1,16 @@
## (WIP)
- Added option to limit the returned API fields using the `?fields` query parameter.
The "fields picker" is applied for `SearchResult.Items` and any other JSON response. For example:
```js
// original: {"id": "RECORD_ID", "name": "abc", "description": "...something very big...", "items": ["id1", "id2"], "expand": {"items": [{"id": "id1", "name": "test1"}, {"id": "id2", "name": "test2"}]}}
// output: {"name": "abc", "expand": {"items": [{"name": "test1"}, {"name": "test2"}]}}
const result = await pb.collection("example").getOne("RECORD_ID", {
expand: "items",
fields: "name,expand.items.name",
})
```
- Added new `./pocketbase admin` console command:
```sh
// creates new admin account