🗄️
Database2M+/wkMIT

sequelize

Sequelize is a promise-based Node.js ORM that supports PostgreSQL, MySQL, MariaDB, SQLite, and Microsoft SQL Server with a comprehensive feature set for relatio

Installation

npm
npm install sequelize
yarn
yarn add sequelize
pnpm
pnpm add sequelize

Import

ESM
import { Sequelize, DataTypes } from 'sequelize';

Quick Example

usage
import { Sequelize, DataTypes } from 'sequelize';

const sequelize = new Sequelize('sqlite::memory:');

const User = sequelize.define('User', {
  name: DataTypes.STRING,
  email: DataTypes.STRING,
});

await sequelize.sync();
const user = await User.create({ name: 'Alice', email: '[email protected]' });

About sequelize

Sequelize is a promise-based Node.js ORM that supports PostgreSQL, MySQL, MariaDB, SQLite, and Microsoft SQL Server with a comprehensive feature set for relational database operations. Sequelize provides model definition with data types, validations, and associations (hasOne, hasMany, belongsTo, belongsToMany), a powerful query interface with where clauses, ordering, grouping, aggregation, and raw queries, and a migration system for version-controlled schema changes. The library supports eager and lazy loading of associations, transactions with automatic rollback, paranoid tables (soft delete), scopes for reusable query filters, hooks for lifecycle events, and connection pooling. Sequelize models define the shape of database tables with columns, types, constraints, and indexes through a JavaScript API. The query builder generates SQL automatically while providing escape hatches for raw SQL when needed. The CLI tool generates migrations, seeders, and model boilerplate files. While Prisma and Drizzle have gained popularity as modern alternatives, Sequelize remains widely used in enterprise applications due to its maturity, multi-dialect support, and comprehensive feature set for complex relational data operations.

Quick Facts

Packagesequelize
CategoryDatabase
Weekly Downloads2M+
LicenseMIT
Installnpm install sequelize

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.