david-plugge / typed-pocketbase

Add types to the PocketBase JavaScript SDK
MIT License
83 stars 10 forks source link

getFirstListItem first arg is typed for unserialized filter #38

Open gavry opened 3 months ago

gavry commented 3 months ago

Hi! Thanks for the awesome library - I much prefer it to the more popular one tbh!

getFirstListItem has typings that makes the first arg ("filter") of type Filter, but the actual method takes in a string and passes it directly to the parent service as the string. This results in an error from pocketbase where the query is incomplete/malformed (400 error).

Edit: forgot to paste reference: https://github.com/david-plugge/typed-pocketbase/blob/92854696b848263ad22cfdd75d00b5d7be5fc9ef/src/client.ts#L231-L236

I assume the solution is to:

Happy to open a pull request if that sounds good to you! Thanks again!

david-plugge commented 2 months ago

Hey, glad you enjoy it and sorry for my late reply!

Good catch, this should only happen when you pass in a filter like ['date', '>=', '2023-01-01'] as the filter methods always return a string. Feel free to create a PR :)