-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate typed PocketBase type #82
Conversation
I love this, thanks for the contribution. Really glad pocketbase added this and I think it'll make this library much easier to use going forward. I think there should be a Before merging I want to test it out and check some edge cases |
Im not sure how expanded relation types and the generic fields for JSON objects will work with this setup. That's not a blocker though |
I agree this would be a good addition. I'll make sure to add it. I also realize I completely forget to update the documentation so I'll make sure that gets added as well. As for expanded relations I totally didn't think of that so I'll have to read up on exactly how the types behave in that case before I give my thoughts 😄 In the worst case you should still be able to pass generic types to the collection methods (like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! I'm traveling at the moment so I appreciate the update for the new SDK. Could you also bump the version in package.json
to 1.1.14?
@patmood I don't know what versioning strategy you're using, but seeing as this adds additional functionality, should this maybe me a minor bump i.e. 1.2.0? |
Thanks again @scriptcoded - Looks good! 🎉 I'll update to 1.2.0 before I release |
Just noticed this one when updating to the latest release. It's such a useful nifty feature Thanks ❤️ |
In the latest release of the PocketBase JavaScript SDK there was added support for providing a typed instance of the client using type assertion. This PR adds a new exported type that fits this shape and can be used directly with PocketBase like this:
To make this work I had to add an import statement to the generated file to get the base types from PocketBase. The resulting file looks something like this:
An alternative if you don't like having this import would be to use generics and have the user pass down the
PocketBase
andRecordService
types, but I think the user experience would be a lot worse.Closes #81