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 install sequelize
yarn add sequelize
pnpm add sequelize
Import
import { Sequelize, DataTypes } from 'sequelize';Quick Example
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
| Package | sequelize |
| Category | Database |
| Weekly Downloads | 2M+ |
| License | MIT |
| Install | npm install sequelize |
Related Packages
Prisma is a next-generation Node.js and TypeScript ORM that provides a declarative data modeling lan…
TypeORM is a full-featured ORM for TypeScript and JavaScript that supports both Active Record and Da…
Knex.js is a batteries-included SQL query builder for Node.js that supports PostgreSQL, MySQL, Maria…
pg (node-postgres) is the standard PostgreSQL client for Node.js, providing low-level access to Post…
mysql2 is a high-performance MySQL client for Node.js that provides prepared statements, non-UTF-8 e…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.