Closed DaniDipp closed 1 year ago
With collection fields like Select and Relation, you can set the maxSelect option to higher than 1, which will return the field as a string array instead of a string. pocketbase-typegen doesn't take this into account when generating the types.
Select
Relation
maxSelect
Here is the example schema that I've created for reproducibility: pb_schema-example.json.txt And the generated types: pocketbase-types-example.ts.txt
Querying the database returns the data like this:
const pocketbase = new PocketBase("http://127.0.0.1:8090/"); const collection = pocketbase.collection(Collections.Collection); const data = await collection.getFullList<CollectionResponse>(200); console.log(data[0]); n { collectionId: 'yi37tasie50pmsd', collectionName: 'collection', created: '2022-12-02 15:25:13.523Z', id: 'xqf3dupg37bwomy', relation_field: [ '79gc39o1et4o73f', 'lkjzpzv2cwaemf3' ], select_field: [ 'choice1' ], updated: '2022-12-02 15:25:13.523Z', expand: {} }
however, the generated type doesn't have the arrays:
{ select_field?: CollectionSelectFieldOptions; relation_field?: string; id: string; created: string; updated: string; collectionId: string; collectionName: Collections; expand?: { ...; }; }
Thanks for finding this! File and relation fields should already handled, but maxSelect on select fields is a bug. I'll fix it!
This should be included in the v1.1.2
With collection fields like
Select
andRelation
, you can set themaxSelect
option to higher than 1, which will return the field as a string array instead of a string. pocketbase-typegen doesn't take this into account when generating the types.Here is the example schema that I've created for reproducibility: pb_schema-example.json.txt And the generated types: pocketbase-types-example.ts.txt
Querying the database returns the data like this:
however, the generated type doesn't have the arrays: