Skip to content

Easily generate TypeGraphql / TypeOrm entities from your postgres database

Notifications You must be signed in to change notification settings

cellis/pg-graphql-typeorm

Repository files navigation

pg-graphql-typeorm

The sole purpose of this code as of inception, is to generate typeorm + typegraphql models from a postgres database.

I followed creating a cli with nodejs, creating a cli with typescript, and unit testing node cli apps to help create this so shout out to those authors.

Usage

yarn ftl -d my_database -s schema_1,schema_2,schema_n -o ./where/toput/entities

Usage with prettier (optional)

yarn ftl -d my_database -s schema_1,schema_2,schema_n -o ./where/toput/entities && yarn typeorm:format

Note: typeorm:format is just package.json script with prettier --write ./src/generated/entities/*.ts

I like to add a script to my package.json:

"scripts": {
...
  "build:entities": "yarn ftl -d my_database -s schema_1,schema_2,schema_n -o ./src/generated/entities && yarn typeorm:format"
}

Todo

  • Allow configs. Loading configs works but haven't decided on to do with the configuration. E.g., exclude some tables from generation, or specific columns in a table or even some pattern type stuff.

Update in version 0.5.0 load config (.ftlrc.js in root project) to decide whether to create relationships for a certain field of a model.

Compatibility

TypeORM: 0.2.32 TypeGraphql: 1.1.1

Notes on development

This was originally called superluminal, but upon trying to publish i noticed that cool name was taken so i renamed. The ftl command will stay though ;)

About

Easily generate TypeGraphql / TypeOrm entities from your postgres database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published