Skip to main content
Version: v7 - alpha

Sequelize v7 (alpha)

npm version npm downloads sponsor Last commit Merged PRs GitHub stars node License

Sequelize is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Amazon Redshift and Snowflake’s Data Cloud. It features solid transaction support, relations, eager and lazy loading, read replication and more.

Sequelize follows Semantic Versioning and the official Node.js LTS schedule. Version 7 of Sequelize officially supports the Node.js versions >=18.0.0.

You are currently looking at the Tutorials and Guides for Sequelize. You might also be interested in the API Reference.

Quick example

import {
Sequelize,
Model,
DataTypes,
InferAttributes,
InferCreationAttributes,
} from '@sequelize/core';
import { Attribute } from '@sequelize/core/decorators-legacy';
import { SqliteDialect } from '@sequelize/sqlite3';

class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
@Attribute(DataTypes.STRING)
declare username: string | null;

@Attribute(DataTypes.DATE)
declare birthday: Date | null;
}

const sequelize = new Sequelize({
dialect: SqliteDialect,
models: [User],
});

await sequelize.sync();

const jane = await User.create({
username: 'janedoe',
birthday: new Date(1980, 6, 20),
});

console.log(jane.toJSON());
info

Sequelize currently only supports the legacy/experimental decorator format. Support for the new decorator format will be added in a future release.

All decorators must be imported from @sequelize/core/decorators-legacy:

import { Attribute, Table } from '@sequelize/core/decorators-legacy';

Using legacy decorators requires to use a transpiler such as TypeScript, Babel or others to compile them to JavaScript. Alternatively, Sequelize also supports a legacy approach that does not require using decorators, but this is discouraged.

If you're using TypeScript, you will also need to configure it to be able to resolve this export, see our Getting Started guide for more information.

To learn more about how to use Sequelize, read the tutorials available in the left menu. Begin with Getting Started.

Supporting the project

Do you like Sequelize and would like to give back to the engineering team behind it?

We have recently created an OpenCollective based money pool which is shared amongst all core maintainers based on their contributions. Every support is wholeheartedly welcome. ❤️