{"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,"search_vec":"'6.37.8':34 '7':37 'activ':38,58 'alpha':42 'base':9 'current':30 'databas':19 'db2':76 'develop':40 'eager/lazy':50 'featur':45 'final':63 'includ':20 'javascript':68 'like':46 'load':51 'maintain':61 'major':66 'mapper':15 'mariadb':23,70 'microsoft':26 'mssql':75 'mysql':22,69 'new':60 'next':65 'node.js':10 'object':13 'object-rel':12 'offer':44 'orm':2,11 'pg':74 'postgr':21,73 'postgresql':72 'project':56 'promis':8 'promise-bas':7 'read':53 'relat':14,49 'releas':67 'replic':54 'robust':6 'seek':59 'sequel':1,3 'server':28 'sql':18,27 'sqlite':24,71 'stabl':31 'support':48 'transact':47 'typescript':77 'various':17 'version':32,36","created_at":"2026-04-18T08:58:41.315839+00:00","updated_at":"2026-04-18T08:58:41.315839+00:00","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","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"sequelize","cli_version":null,"type":"library","homepage":"https://sequelize.org","github":"https://github.com/sequelize/sequelize","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/sequelize","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-17","install_tag":null}}