1.1.1 โข Published 5 months ago
@abzn/sequelize-model-generator v1.1.1
๐ Sequelize Model Generator
A simple CLI tool to generate Sequelize model files from existing PostgreSQL tables.
โจ Features
- โ Supports PostgreSQL
- ๐งฑ Follows Sequelize
modelstructure (compatible with controller-service pattern) - โ๏ธ Customizable model and file name
- ๐ Output to desired directory
- ๐ Option for PascalCase and .model suffix for filenames
- ๐ Uses
.envfor DB credentials - ๐งช Easy to use for existing or new Node.js projects
๐ฆ Installation
npm install @abzn/sequelize-model-generatorYou 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
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--name | -n | string | - | Custom name for the Sequelize model |
--out | -0 | string | ./models | Output directory for the model file |
--pascal-case | -pc | boolean | false | Use PascalCase for the filename |
--add-suffix-model | - | boolean | true | Append .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-modelThis 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_passwordor :
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=your_database
DB_USERNAME=your_user
DB_PASSWORD=your_password