{"id":10417,"library":"sequelize","title":"Sequelize ORM","description":"Sequelize is a robust, promise-based Node.js ORM (Object-Relational Mapper) for various SQL databases including Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL Server. The current stable version is 6.37.8, with version 7 actively under development in alpha. It offers features like transaction support, relations, eager/lazy loading, and read replication. The project is actively seeking new maintainers to finalize the next major release.","status":"active","version":"6.37.8","language":"javascript","source_language":"en","source_url":"https://github.com/sequelize/sequelize","tags":["javascript","mysql","mariadb","sqlite","postgresql","postgres","pg","mssql","db2","typescript"],"install":[{"cmd":"npm install sequelize","lang":"bash","label":"npm"},{"cmd":"yarn add sequelize","lang":"bash","label":"yarn"},{"cmd":"pnpm add sequelize","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"wrong":"const { Sequelize } = require('sequelize');","symbol":"Sequelize","correct":"import { Sequelize } from 'sequelize';"},{"wrong":"const { DataTypes } = require('sequelize');","symbol":"DataTypes","correct":"import { DataTypes } from 'sequelize';"},{"wrong":"const { Model } = require('sequelize');","symbol":"Model","correct":"import { Model } from 'sequelize';"}],"quickstart":{"code":"import { Sequelize, DataTypes, Model } from 'sequelize';\n\nconst sequelize = new Sequelize({\n  dialect: 'sqlite',\n  storage: 'database.sqlite',\n  logging: false // Disable logging for cleaner output\n});\n\nclass User extends Model {}\n\nUser.init({\n  id: {\n    type: DataTypes.INTEGER,\n    autoIncrement: true,\n    primaryKey: true\n  },\n  username: {\n    type: DataTypes.STRING,\n    allowNull: false,\n    unique: true\n  },\n  email: {\n    type: DataTypes.STRING,\n    allowNull: false,\n    unique: true\n  }\n}, {\n  sequelize,\n  modelName: 'User'\n});\n\nasync function run() {\n  try {\n    await sequelize.authenticate();\n    console.log('Connection has been established successfully.');\n\n    await sequelize.sync({ force: true }); // This will drop existing tables\n    console.log('All models were synchronized successfully.');\n\n    const jane = await User.create({ username: 'JaneDoe', email: 'jane.doe@example.com' });\n    console.log(`Created user: ${jane.username}`);\n\n    const users = await User.findAll();\n    console.log('All users:', users.map(u => u.toJSON()));\n\n  } catch (error) {\n    console.error('Unable to connect to the database:', error);\n  } finally {\n    await sequelize.close();\n  }\n}\n\nrun();","lang":"typescript","description":"This quickstart demonstrates how to connect to an SQLite database, define a User model, synchronize the schema, create a new user, and fetch all users. It uses `sequelize.sync({ force: true })` for simplicity, which will drop and re-create tables on each run."},"warnings":[{"fix":"Refer to the official upgrade guide for detailed instructions: https://sequelize.org/docs/v6/other-topics/upgrade-to-v6","message":"Upgrading from Sequelize v5 to v6 introduces several breaking changes that require code modifications.","severity":"breaking","affected_versions":"v5.x to v6.x"},{"fix":"Upgrade to Sequelize v6.37.8 or higher immediately to apply the security fix.","message":"A security vulnerability (CVE-2026-30951) allowed validation bypass in JSON where clauses, potentially leading to SQL injection.","severity":"breaking","affected_versions":">=6.0.0 <6.37.8"},{"fix":"Install the appropriate driver for your database, e.g., `npm install pg` for PostgreSQL.","message":"Sequelize requires a separate database dialect driver package to be installed manually (e.g., 'pg' for PostgreSQL, 'mysql2' for MySQL, 'sqlite3' for SQLite).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider engaging with the community or contributing if specific features or urgent fixes are critical for your project. Join their Slack at sequelize.org/slack.","message":"The Sequelize project is actively seeking new maintainers, which might impact the pace of feature development or critical bug fixes for future major versions if not enough contributors join.","severity":"gotcha","affected_versions":"v6.37.6 onwards (as per README announcement)"}],"env_vars":null,"last_verified":"2026-04-18T00:00:00.000Z","next_check":"2026-07-17T00:00:00.000Z","problems":[{"fix":"Ensure your database server is running and accessible. Verify host, port, username, and password in your Sequelize configuration. Check firewall rules if applicable.","cause":"The database server is not running, is inaccessible, or connection details are incorrect.","error":"SequelizeConnectionError: connect ECONNREFUSED 127.0.0.1:5432"},{"fix":"Install the correct driver for your database: `npm install pg` (PostgreSQL), `npm install mysql2` (MySQL/MariaDB), `npm install sqlite3` (SQLite).","cause":"The database dialect driver required by Sequelize (e.g., 'pg', 'mysql2') has not been installed.","error":"Error: Please install 'pg' module manually"},{"fix":"Implement checks (e.g., using `Model.findOrCreate`) before creating records, or catch the `SequelizeUniqueConstraintError` and handle the duplicate entry gracefully.","cause":"An attempt was made to insert or update a record with a value that violates a unique constraint on a database field.","error":"SequelizeUniqueConstraintError: Validation error"},{"fix":"Run database migrations to ensure your schema is up-to-date with your Sequelize models. Double-check column names and aliases in your queries.","cause":"The database schema does not match the Sequelize model definition, often due to missing or outdated migrations.","error":"SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column '...' in 'field list'"}],"ecosystem":"npm"}