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: about 2 months 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 (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-12T23:42:59.000Z (over 6 years ago)
- Last Synced: 2025-03-29T01:34:28.526Z (2 months 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
[](https://travis-ci.org/gajus/database-types)
[](https://coveralls.io/github/gajus/database-types)
[](https://www.npmjs.org/package/database-types)
[](https://github.com/gajus/canonical)
[](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```