1.3.0 • Published 6 years ago

elbowgrease v1.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

ElbowGrease

npm Build Status

When you need TypeScript classes corresponding to your database tables - you need some ElbowGrease.

MySQL and PostgreSQL supported.

Super lightweight: not a single dependency

Example

With config:

{
    "extends": "AutoBase",
    "attribute": "@serializable"
}

Will result in

export class customer extends AutoBase
{
    @serializable
    id: number
    
    @serializable
    email: string
    
    @serializable
    password: string | null
    
    @serializable
    created_at: Date
}

Installing ElbowGrease

npm install -g elbowgrease

And depending on the database you're going to connect to:

npm install -g pg    # for postgres
npm install -g mysql # for mysql

Generating the code

elbowgrease postgres://user:password@host/database output.ts
elbowgrease mysql://user:password@host/database output.ts

Using elbowgrease.json config file

Just run your generation with

elbowgrease

with elbowgrease.json in curren directory

{
    "connectionData": "postgres://user:password@host/database",
    "output": "ts/types.ts"
}
{
    "connectionData": {
        "host": "hostname",
        "user": "username"
    },
    "output": "ts/types.ts"
}

Options

{
    "excludeTables": [],
    "schema": "public",
    "extends": "",
    "dialect": "postgres",
    "exportKeyword": "class",
    "attribute": "",
    "indent": "    ",
    "memberCase": "none",
    "typeCase": "none",
    "prepend": "",
    "append": "",
    "lineFeed": "\n",
    "header": true,
    "additional_info": {}
}
1.3.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago