Command line interface for dbschema-parser
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
generated
LICENSE
README.md
index.js
package-lock.json
package.json v1.2.3 Oct 3, 2017

README.md

dbschema-parser-cli

Command line interface for dbschema-parser. Generates database-specific resource files from the .dbs files output by Wise Coders Solutions' DbSchema Diagram Designer and Query Tool.

Limitations

Currently, the parser only generates from MySql to Mongoose (MongoDB). The CLI is meant to be plugable, however only one generator has been created so far (dbschema-mongoose).

Installation

npm install -g dbschema-parser-cli

Usage

Options:

-d | --database : Selected database (default: all)
-e | --enhance : Use enhanced output (if available) (default: false)
-f | --format : Output format.  (default: mongoose)
-i | --input  : (required) Source DbSchema file.
-o | --output : Output folder path.  (default: ./generated/%datetime%)
-r | --reduce : Reduce output path for selected objects (default: false)
-s | --schema : Selected schema (default: all)
-I | --index : Generate index files (default: false)
-O | --overwrite : Overwrite existing files (default: false)

Example Usage:

Important: The following examples were generated with the dbschema-mongoose generator. Other generates will output different results.

Minimal Syntax:

The only required parameter is the input file (-i or --input):

dbschema -i ../dbschema-parser/examples/geography/resources.dbs

Note only the essential files are generated in a hierarchal structure:

\ generated
+- \ 20170717211353
      \ resources
         \ geography
         +- city.js
            country.js
            postal_code.js
            state.js
            

Generating Index Files:

Index files are generated by adding the -I (or --index) switch:

dbschema -I -i ../dbschema-parser/examples/geography/resources.dbs

Generates the following Mongoose / MongoDB model files:

\ generated
+- \ 20170717211353
   +- index.js
      \ resources
      +- index.js
         \ geography
         +- city.js
            country.js
            index.js
            postal_code.js
            state.js
            

Reducing Output Path & Limiting Selections:

Including the -d (or --database), with the name of the database, causes all other databases to be ignored. Adding the -r (or --reduce) switch prevents unnecessary folders from being created, thus creating a flatter output structure:

dbschema -r -d resources -I -i ../dbschema-parser/examples/geography/resources.dbs

The top-most folder was not output because of the -r (or --reduce) switch. Since only database was output there was no need for an index file or subdirectory:

\ generated
+- \ 20170717211353
    +- index.js
       \ geography
       +- city.js
          country.js
          index.js
          postal_code.js
          state.js
            
Extreme Minimal Output:

Similar to above, adding the -s (or --schema) switch, with the schema name, causes all other schemas to be ignored (-d is required in this scenario):

dbschema -r -d resources -s geography -I -i ../dbschema-parser/examples/geography/resources.dbs

Specifying both the schema and database, along with the -r (or --reduce) switch causes minimal output to be generated and the flattest structure:

\ generated
+- \ 20170717211353
   +- city.js
      country.js
      index.js
      postal_code.js
      state.js
            

About MEAN Factory

MEAN Factory is an initiative to help teach software development focusing on the MEAN Stack (Mongo, ExpressJS, AngularJS, NodeJS). For more information, visit our web site or email us:

http://meanfactory.com
info@meanfactory.com