Giter Site home page Giter Site logo

database-types's Introduction

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:[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=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

database-types's People

Contributors

gajus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

database-types's Issues

Add MongoDB support

hi,

it would be nice to have support for mongodb. (in core or via a dedicated plugin)
is this architecture already supporting plugins?
if not you should define an interface to be implemented by plugins and leave the core agnostic to the db driver being used.

bool is typed as any

CREATE TABLE card (
	id int8 NOT NULL DEFAULT,
	active bool NOT NULL DEFAULT true,
}

result

export type CardRecordType = {|
  +active: any,
  +id: number,
|};

add plugins support

hi,

it would be nice to define a common generic interface that has to be implemented by db plugins in order to facilitate the contributions from the community. the architecture should also be updated to support plugins. see #4 .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.