1.1.1 โ€ข Published 5 months ago

@abzn/sequelize-model-generator v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

๐Ÿš€ Sequelize Model Generator

A simple CLI tool to generate Sequelize model files from existing PostgreSQL tables.


โœจ Features

  • โœ… Supports PostgreSQL
  • ๐Ÿงฑ Follows Sequelize model structure (compatible with controller-service pattern)
  • โš™๏ธ Customizable model and file name
  • ๐Ÿ“ Output to desired directory
  • ๐Ÿ”  Option for PascalCase and .model suffix for filenames
  • ๐Ÿ” Uses .env for DB credentials
  • ๐Ÿงช Easy to use for existing or new Node.js projects

๐Ÿ“ฆ Installation

npm install  @abzn/sequelize-model-generator

You can also use it globally (with -g).


๐Ÿ› ๏ธ Usage

npx genmodel --help
npx genmodel <table> [options]

Arguments

  • <table> (required) Name of the PostgreSQL table to generate the Sequelize model from.

Options

OptionAliasTypeDefaultDescription
--name-nstring-Custom name for the Sequelize model
--out-0string./modelsOutput directory for the model file
--pascal-case-pcbooleanfalseUse PascalCase for the filename
--add-suffix-model-booleantrueAppend .model suffix to filename (use --no-add-suffix-model to disable)
--help---Show help message

๐ŸŒฑ Example

npx genmodel users -n User -o ./models --pascal-case --no-add-suffix-model

This command generates a file User.js in the ./models directory.

๐Ÿ“„ .env File

Make sure you have a .env file in your project root with the following PostgreSQL connection settings:

DB_HOST=localhost
DB_PORT=5432
DB_NAME=your_database
DB_USER=your_user
DB_PASS=your_password

or :

DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=your_database
DB_USERNAME=your_user
DB_PASSWORD=your_password
1.1.1

5 months ago

1.1.0

5 months ago

1.0.1

6 months ago