@ist-group/pg-typegen
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

Description

Generate typescript interfaces from a postgresql schema.

Config

The type-gen will look for database connection information in the config. The connection information is directly put into pg-promise. See pg-promise connection syntax for more information if needed.

Expected propertes:

host: string
port: number
database: string
user: string
password: string

Example:

{
  "host": "localhost",
  "port": 5432,
  "database": "local-database",
  "user": "root",
  "password": "root"
}

There is a possibility to set a root of the properties inside the json file with --config-root. This is useful if the database information is not at root level.

Example:

pg-types --config ./config.json --config-root db.config --output ./output.ts

./config.json
{
  "db": {
    "config": {
      "host": "localhost",
      "port": 5432,
      "database": "local-database",
      "user": "root",
      "password": "root"
    }
  }
}

Options

--config <config>, -c <config> Set a relative path to the config to use.

--config-root <path.to.properties>, -r <path.to.properties> Set a root of the expected properties in the given config file.

--desnake, -d Replace snake_casing with CamelCasing in the generated output.

interface table_name {
  column_name: number;
}

will become

interface TableName {
  columnName: number;
}

--output <filename>, -o <filename> Output filename.

Examples

pg-types --config ./config.json ./output.ts, pg-types --config ./config.json --config-root db.config --output ./output.ts, pg-types --config ./config.json -d ./output.ts,

Readme

Keywords

none

Package Sidebar

Install

npm i @ist-group/pg-typegen

Weekly Downloads

6

Version

0.0.9

License

MIT

Unpacked Size

33.3 kB

Total Files

10

Last publish

Collaborators

  • omer.irfan
  • rhine
  • gabts