Skip to content

codemix/database-types

This branch is 1 commit behind gajus/database-types:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a23c40e · Nov 11, 2017

History

15 Commits
Nov 11, 2017
Nov 11, 2017
Jun 6, 2017
Jun 6, 2017
Jun 6, 2017
Jun 6, 2017
Jun 6, 2017
Jun 6, 2017
Jun 6, 2017
Jun 6, 2017
Jun 6, 2017
Nov 11, 2017
Nov 11, 2017

Repository files navigation

database-types

Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

A generic type generator for various databases.

The current supported database backend is Postgres. Track #1 issue for MySQL support.

Use case

If you are developing applications in JavaScript and using either of the strict type systems, then you can use database-types to generate types describing the database.

Example usage

Generating Flow types

export DATABASE_TYPES_DATABASE_CONNECTION_URI=postgres://postgres:password@127.0.0.1/test
export DATABASE_TYPES_COLUMN_FILTER="return !['raster_overviews', 'raster_columns', 'geometry_columns', 'geography_columns', 'spatial_ref_sys'].includes(tableName)"
export DATABASE_TYPES_DIALECT=flow

database-types generate-types > ./types.js

This generates file containing Flow type declarations in the following format:

export type ReservationSeatRecordType = {|
  +createdAt: string,
  +id: number,
  +reservationId: number,
  +seatId: number
|};

export type TicketTypeRecordType = {|
  +cinemaId: number,
  +id: number,
  +name: string,
  +nid: string,
  +policy: string | null
|};

// ...

CLI

$ npm install database-types -g
$ database-types --help

About

A generic type generator for various databases.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%