Skip to content

octavonu/pocketbase-types-generator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Pocketbase Types Generator

Generate TypeScript types from your PocketBase collections in seconds.

Install

  1. Clone the repository
  2. cd pocketbase-types-generator
  3. npm install

Usage

  1. Export your pocketbase schema using the export option on the Admin in your pocketbase db.
  2. Place the file in the current folder.
  3. Rename the file to schema.json
  4. Open the terminal and run npm run generate
  5. The script will generate the file pb.types.ts in the current folder
  6. Copy the pb.types.ts to your project

This creates pb.types.ts with interfaces for all your collections:

interface Base {
  id: string;
  created: string;
  updated: string;
}

interface User extends Base {
  name: string;
  avatar: string;
  post_id: string; 
}

interface Post extends Base {
  title: string;
  content: string;
  author_id: string
}

Features

  • Generates TypeScript interfaces from PocketBase collections
  • Supports all PocketBase field types
  • Excludes views by default
  • Adds proper nullability
  • Supports custom fields

License

MIT © thisuxhq

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%