typed-pocketbase icon indicating copy to clipboard operation
typed-pocketbase copied to clipboard

getFirstListItem first arg is typed for unserialized filter

Open gavry opened this issue 1 year ago • 1 comments

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:

  • Check if it's of type string
  • If yes, pass directly
  • If no, serialize it and pass it

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

gavry avatar May 16 '24 22:05 gavry

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 :)

david-plugge avatar Jun 20 '24 13:06 david-plugge