-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
9 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,10 @@ This will produce types for all your PocketBase collections to use in your front | |
## Version Support | ||
|
||
| PocketBase | pocketbase-typegen | npx command | | ||
|------------|--------------------| ------------------------------------------------------------------------------ | | ||
| v0.23.x | v1.2.x | npx pocketbase-typegen --db ./pb_data/data.db --out pocketbase-types.ts | | ||
| v0.8.x | v1.1.x | npx [email protected] --db ./pb_data/data.db --out pocketbase-types.ts | | ||
| ---------- | ------------------ | ------------------------------------------------------------------------------ | | ||
| v0.23.x | v1.3.x | npx pocketbase-typegen --db ./pb_data/data.db --out pocketbase-types.ts | | ||
| v0.18.x | v1.2.x | npx [email protected] --db ./pb_data/data.db --out pocketbase-types.ts | | ||
| v0.8.x | v1.1.x | npx [email protected] --db ./pb_data/data.db --out pocketbase-types.ts | | ||
| v0.7.x | v1.0.x | npx [email protected] --db ./pb_data/data.db --out pocketbase-types.ts | | ||
|
||
## Usage | ||
|
@@ -83,10 +84,10 @@ Using PocketBase SDK v0.18.3+, collections can be [automatically typed](https:// | |
```typescript | ||
import { TypedPocketBase } from "./pocketbase-types" | ||
|
||
const pb = new PocketBase('http://127.0.0.1:8090') as TypedPocketBase | ||
const pb = new PocketBase("http://127.0.0.1:8090") as TypedPocketBase | ||
|
||
await pb.collection('tasks').getOne("RECORD_ID") // -> results in TaskResponse | ||
await pb.collection('posts').getOne("RECORD_ID") // -> results in PostResponse | ||
await pb.collection("tasks").getOne("RECORD_ID") // -> results in TaskResponse | ||
await pb.collection("posts").getOne("RECORD_ID") // -> results in PostResponse | ||
``` | ||
|
||
Alternatively, you can use generic types for each request, eg: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters