New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pocketbase-typegen

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pocketbase-typegen

Generate pocketbase record types from your database

  • 1.0.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
250
decreased by-82.27%
Maintainers
1
Weekly downloads
 
Created
Source

Pocketbase Typegen

Generate typescript definitions from your pocketbase.io schema.

Quickstart

npx pocketbase-typegen --db ./pb_data/data.db --out pocketbase-types.ts

This will produce types for all your PocketBase collections to use in your frontend typescript codebase.

Usage

Options:
  -V, --version          output the version number
  -d, --db <char>        path to the pocketbase SQLite database
  -j, --json <char>      path to JSON schema exported from pocketbase admin UI
  -u, --url <char>       URL to your hosted pocketbase instance. When using this options you must also provide email and password options.
  -e, --email <char>     email for an admin pocketbase user. Use this with the --url option
  -p, --password <char>  password for an admin pocketbase user. Use this with the --url option
  -o, --out <char>       path to save the typescript output file (default: "pocketbase-types.ts")
  -h, --help             display help for command

DB example:

npx pocketbase-typegen --db ./pb_data/data.db

JSON example (export JSON schema from the pocketbase admin dashboard):

npx pocketbase-typegen --json ./pb_schema.json

URL example:

npx pocketbase-typegen --url https://myproject.pockethost.io --email admin@myproject.com --password 'secr3tp@ssword!'

Example output

The output is a typescript file pocketbase-types.ts (example) which will contain:

  • An enum of all collections
  • One type for each collection (eg ProfilesRecord)
  • One response type for each collection (eg ProfilesResponse) which includes base fields like id, updated, created
  • A type CollectionRecords mapping each collection name to the record type

In the upcoming PocketBase SDK v0.8 you will be able to use generic types when fetching records, eg:

pb.collection('tasks').getOne<Task>("RECORD_ID") // -> results in Promise<Task>

Keywords

FAQs

Package last updated on 07 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc