Registry / database / sequelize-models

sequelize-models

JSON →
library1.4.0jsnpmunverified

sequelize-models (v1.4.0) is a utility library for SequelizeJS ORM that automatically loads database tables and associations as Sequelize models. It supports MySQL and PostgreSQL, and allows explicit model definitions with associations. Released in 2018 and no longer actively maintained, the project is planned for a rewrite. Key differentiators: auto-loading from database schema, simplified model syntax, and association definitions in one place. Requires Node.js >=4 and Sequelize 4.37.x.

npm install sequelize-models
INSTALL
IMPORT
SIG · SEQUELIZE-MODELS
S
sequelize-models
databasejavascriptv1.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SequelizeModels
const SequelizeModels = require('sequelize-models');
import SequelizeModels from 'sequelize-models';
This package uses CommonJS. ESM import may fail depending on Node version and module resolution.
SequelizeModels
const SequelizeModels = require('sequelize-models').default;
Some builds export as default; check the package exports. If require returns an object with default property, use .default.
new SequelizeModels
const seqModels = new SequelizeModels(config);
Constructor expects config object with connection, models, and sequelizeOptions.

Instantiates SequelizeModels with MySQL connection, auto-loads models from database schema, and logs loaded model names.

const SequelizeModels = require('sequelize-models'); var seqModels = new SequelizeModels({ connection: { host: '127.0.0.1', dialect: 'mysql', username: 'root', schema: 'sequelize_test', password: process.env.DB_PASSWORD ?? '' }, models: { autoLoad: true, path: '/models' }, sequelizeOptions: { define: { freezeTableName: true, underscored: true } } }); seqModels.getSchema() .then(schema => { console.log('Models loaded:', Object.keys(schema.models)); }) .catch(err => { console.error(err); });
Debug
Known issues
deprecatedPackage uses Sequelize 4.x which is outdated. Sequelize v5+ has breaking changes.
fix
Consider using sequelize@>=5 and this package may not work. Switch to sequelize-auto or define models manually.
affects: >=1.0.0
breakingRequires Node.js >= 4. Node.js 4 is end-of-life; may fail on newer Node versions.
fix
Upgrade Node.js to latest LTS, but package may not be compatible. Test in your environment.
affects: >=1.0.0
gotchaThe package expects a 'schema' property in connection config, not 'database'.
fix
Use 'schema' instead of 'database' in connection configuration.
affects: >=1.0.0
gotchaNo ESM support; require() only.
fix
Use CommonJS require(). If using ESM, use createRequire or dynamic import.
affects: >=1.0.0
gotchaAuto-load may fail if database tables have no primary keys or unsupported column types.
fix
Ensure all tables have primary keys and use supported types (string, integer, date, boolean, etc.).
affects: >=1.0.0
Errors
Common errors & fixes
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
MySQL 8 uses caching_sha2_password by default, but mysql2 version pinned may not support it.
fix
Install mysql2@>=2.0.0 or alter MySQL user to use mysql_native_password.
Error: Cannot find module 'pg-hstore'
Missing peer dependency pg-hstore when using PostgreSQL.
fix
Run 'npm install pg pg-hstore'.
TypeError: SequelizeModels is not a constructor
Importing incorrectly with ESM or destructuring the default export.
fix
Use 'const SequelizeModels = require('sequelize-models');' (CommonJS). If using ESM, try 'import SequelizeModels from 'sequelize-models';'.
Error: getSchema is not a function
Instance not created properly; likely missing 'new' keyword.
fix
Instantiate with 'new SequelizeModels(config)'.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
pgoptionalPeer dependency for PostgreSQL support
pg-hstoreoptionalPeer dependency for pg-hstore required by pg
mysql2optionalPeer dependency for MySQL support
Agent activity
6 hits · last 30 days
node
4
Meta
2
Resources
sequelize-models — npm install sequelize-models · libregistry