Code Monkey home page Code Monkey logo

pg-generator's Introduction

Template Based Scaffolding for PostgreSQL

pg-generator is a command line utility which generates files for each table and schema of a PostgreSQL database.
  • Reverse engineers PostgreSQL database,
  • Executes nunjucks templates for each table, schema and for database,
  • Makes database objects available to templates using pg-structure.

pg-generator takes your burden of manually creating ORM files or any other files which are based on database structure.

Installation

$ npm install -g pg-generator

Sequelize Example

See sequelize template for usage and details.

$ pgen template sequelize -t sequelize-template
$ pgen exec sequelize-template -d our_crm -u user -p tOpSeCrEt -t model

First command copies one of the builtin templates (sequelize) into target directory (sequelize-template). Second command generates files based on given template (sequelize-template) into target directory (model).

Basic Usage

  1. Use pgen template to copy one of the builtin templates or create your own template. (You can use base template for starting up.)
  2. Use pgen exec to create files based on your template.

Template

Creating a template from scratch is easy. Execute command below:

$ pgen template base -t my-template

To see a basic example execute following command from shell and examine files in tutorial-example directory.

$ pgen template tutorial -t tutorial-template

For a full fledged example which we use at Fortibase, see Sequelize Example above.

For Low Level Direct Access: pg-structure

If you prefer lower level methods to directly access PostgreSQL structure to build your own generators. You can check pg-structure module which is used to build this module and provides direct access to database structure.

Full Documentation

Documentation is available on pg-generator.com

Special Thanks

pg-generator is developed under sponsorship of Fortibase and released as open source. See license.

Also documentation is auto generated thanks to:

Contributions

  • For contribution please send pull requests with tests on GitHub.
  • Send bugs and feature requests to GitHub Issues.

pg-generator's People

Contributors

mcouzinet avatar ozum avatar robertpallas avatar viniciuspinto avatar wuher avatar

Watchers

 avatar

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.