@postgresql-typed/cli
TypeScript icon, indicating that this package has built-in type declarations

0.10.1 • Public • Published

@PostgreSQL-Typed/CLI

Generate TypeScript types to be used with the PostgreSQL-Typed ecosystem from your PostgreSQL database.

Table of Contents Installation
Usage
Ecosystem
License

Installation

Install @postgresql-typed/cli as a development dependency.

npm install --save-dev @postgresql-typed/cli

Usage

To initialize a new configuration file for PostgreSQL-Typed in your current working directory, run pgt init.

npx pgt init

By default, this will create a pgt.config.ts file in your current working directory with the following contents:

import { defineConfig } from "@postgresql-typed/cli/config";

export default defineConfig({
	cli: {
		connections: [
			process.env.DATABASE_URI
		],
	},
});

You can then run pgt gen to generate TypeScript types for your database.

Make sure to set the DATABASE_URI environment variable to your database connection string before running this command.
You can use a .env file to set environment variables. This file will be automatically loaded by pgt.

NOTE: If your project uses ESM modules, you will need to set the cli.type option to "esm" in your pgt.config.ts file.

npx pgt gen

By default, this will create a __generated__ directory in your current working directory with the generated TypeScript types.

You can customize the output directory and many other options by editing the pgt.config.ts file. See the JSDoc comments when hovering for more information.

You can also run pgt --help to see a list of available commands.

Ecosystem

This package is part of the PostgreSQL-Typed ecosystem.

License

Mozilla Public License 2.0

Package Sidebar

Install

npm i @postgresql-typed/cli

Weekly Downloads

12

Version

0.10.1

License

MPL-2.0

Unpacked Size

392 kB

Total Files

252

Last publish

Collaborators

  • bas950