Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gajus/database-types
A generic type generator for various databases.
https://github.com/gajus/database-types
flow flowtype javascript postgres postgresql
Last synced: 18 days ago
JSON representation
A generic type generator for various databases.
- Host: GitHub
- URL: https://github.com/gajus/database-types
- Owner: gajus
- License: other
- Created: 2017-06-06T17:03:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-12T23:42:59.000Z (almost 6 years ago)
- Last Synced: 2024-10-05T13:48:42.321Z (29 days ago)
- Topics: flow, flowtype, javascript, postgres, postgresql
- Language: JavaScript
- Size: 15.6 KB
- Stars: 26
- Watchers: 4
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flow - database-types - A generic type generator for various databases. (Packages / Helpers)
README
# database-types
[![Travis build status](http://img.shields.io/travis/gajus/database-types/master.svg?style=flat-square)](https://travis-ci.org/gajus/database-types)
[![Coveralls](https://img.shields.io/coveralls/gajus/database-types.svg?style=flat-square)](https://coveralls.io/github/gajus/database-types)
[![NPM version](http://img.shields.io/npm/v/database-types.svg?style=flat-square)](https://www.npmjs.org/package/database-types)
[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)A generic type generator for various databases.
The current supported database backend is Postgres. Track [#1 issue](https://github.com/gajus/database-types/issues/1) 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
```bash
export DATABASE_TYPES_DATABASE_CONNECTION_URI=postgres://postgres:[email protected]/test
export DATABASE_TYPES_COLUMN_FILTER="return !['raster_overviews', 'raster_columns', 'geometry_columns', 'geography_columns', 'spatial_ref_sys'].includes(tableName)"
export DATABASE_TYPES_DIALECT=flowdatabase-types generate-types > ./types.js
```
This generates file containing Flow type declarations in the following format:
```js
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
```bash
$ npm install database-types -g
$ database-types --help```