Gathering detailed insights and metrics for sequelize-auto-xiaocaibird-fork
Gathering detailed insights and metrics for sequelize-auto-xiaocaibird-fork
Gathering detailed insights and metrics for sequelize-auto-xiaocaibird-fork
Gathering detailed insights and metrics for sequelize-auto-xiaocaibird-fork
Automatically generate bare sequelize models from your database.
npm install sequelize-auto-xiaocaibird-fork
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
305 Commits
1 Watchers
179 Branches
1 Contributors
Updated on Sep 16, 2018
Latest Version
0.5.2
Package Id
sequelize-auto-xiaocaibird-fork@0.5.2
Unpacked Size
72.12 kB
Size
18.01 kB
File Count
22
NPM Version
6.1.0
Node Version
10.7.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
#fork sequelize-auto(0.4.29)
Automatically generate models for SequelizeJS via the command line.
npm install -g sequelize-auto
You will need to install the correct dialect binding globally before using sequelize-auto.
Example for MySQL/MariaDB
npm install -g mysql
Example for Postgres
npm install -g pg pg-hstore
Example for Sqlite3
npm install -g sqlite
Example for MSSQL
npm install -g mssql
[node] sequelize-auto -h <host> -d <database> -u <user> -x [password] -p [port] --dialect [dialect] -c [/path/to/config] -o [/path/to/models] -t [tableName] -C
Options:
-h, --host IP/Hostname for the database. [required]
-d, --database Database name. [required]
-u, --user Username for database.
-x, --pass Password for database.
-p, --port Port number for database.
-c, --config JSON file for Sequelize's constructor "options" flag object as defined here: https://sequelize.readthedocs.org/en/latest/api/sequelize/
-o, --output What directory to place the models.
-e, --dialect The dialect/engine that you're using: postgres, mysql, sqlite
-a, --additional Path to a json file containing model definitions (for all tables) which are to be defined within a model's configuration parameter. For more info: https://sequelize.readthedocs.org/en/latest/docs/models-definition/#configuration
-t, --tables Comma-separated names of tables to import
-T, --skip-tables Comma-separated names of tables to skip
-C, --camel Use camel case to name models and fields
-n, --no-write Prevent writing the models to disk.
-s, --schema Database schema from which to retrieve tables
-z, --typescript Output models as typescript with a definitions file.
sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres
Produces a file/files such as ./models/Users.js which looks like:
/* jshint indent: 2 */
module.exports = function(sequelize, DataTypes) {
return sequelize.define('Users', {
'id': {
type: DataTypes.INTEGER(11),
allowNull: false,
primaryKey: true,
autoIncrement: true
},
'username': {
type: DataTypes.STRING,
allowNull: true
},
'touchedAt': {
type: DataTypes.DATE,
allowNull: true
},
'aNumber': {
type: DataTypes.INTEGER(11),
allowNull: true
},
'bNumber': {
type: DataTypes.INTEGER(11),
allowNull: true
},
'validateTest': {
type: DataTypes.INTEGER(11),
allowNull: true
},
'validateCustom': {
type: DataTypes.STRING,
allowNull: false
},
'dateAllowNullTrue': {
type: DataTypes.DATE,
allowNull: true
},
'defaultValueBoolean': {
type: DataTypes.BOOLEAN,
allowNull: true,
defaultValue: '1'
},
'createdAt': {
type: DataTypes.DATE,
allowNull: false
},
'updatedAt': {
type: DataTypes.DATE,
allowNull: false
}
}, {
tableName: 'Users',
freezeTableName: true
});
};
Which makes it easy for you to simply Sequelize.import it.
For the -c, --config
option the following JSON/configuration parameters are defined by Sequelize's options
flag within the constructor. For more info:
https://sequelize.readthedocs.org/en/latest/api/sequelize/
1var SequelizeAuto = require('sequelize-auto') 2var auto = new SequelizeAuto('database', 'user', 'pass'); 3 4auto.run(function (err) { 5 if (err) throw err; 6 7 console.log(auto.tables); // table list 8 console.log(auto.foreignKeys); // foreign key list 9}); 10 11With options: 12var auto = new SequelizeAuto('database', 'user', 'pass', { 13 host: 'localhost', 14 dialect: 'mysql'|'mariadb'|'sqlite'|'postgres'|'mssql', 15 directory: false, // prevents the program from writing to disk 16 port: 'port', 17 additional: { 18 timestamps: false 19 //... 20 }, 21 tables: ['table1', 'table2', 'table3'] 22 //... 23})
Add -z to cli options or typescript: true
to programmatic options. Model usage in a ts file:
1// All models, can put in or extend to a db object at server init 2import * as dbTables from './models/db.tables'; 3const tables = dbTables.getModels(sequelize); //:dbTables.ITable 4tables.Device.findAll 5// Single models 6import * as dbDef from './models/db.d'; 7const devices:dbDef.DeviceModel = sequelize.import('./models/Device'); 8devices.findAll
You must setup a database called sequelize_auto_test
first, edit the test/config.js
file accordingly, and then enter in any of the following:
# for all
npm run test
# mysql only
npm run test-mysql
# postgres only
npm run test-postgres
# postgres native only
npm run test-postgres-native
# sqlite only
npm run test-sqlite
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More