Sequelize v7 (alpha)
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 ^14.17,0
, ^16.0.0
. Other version might be working as well.
You are currently looking at the Tutorials and Guides for Sequelize. You might also be interested in the API Reference.
Quick example
- TypeScript
- JavaScript (CJS)
import { Sequelize, Model, DataTypes, InferAttributes, InferCreationAttributes } from 'sequelize';
const sequelize = new Sequelize('sqlite::memory:');
class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
declare username: string | null,
declare birthday: Date | null,
}
User.init({
username: DataTypes.STRING,
birthday: DataTypes.DATE
}, { sequelize, modelName: 'user' });
(async () => {
await sequelize.sync();
const jane = await User.create({
username: 'janedoe',
birthday: new Date(1980, 6, 20),
});
console.log(jane.toJSON());
})();
const { Sequelize, Model, DataTypes } = require('sequelize');
const sequelize = new Sequelize('sqlite::memory:');
class User extends Model {}
User.init({
username: DataTypes.STRING,
birthday: DataTypes.DATE
}, { sequelize, modelName: 'user' });
(async () => {
await sequelize.sync();
const jane = await User.create({
username: 'janedoe',
birthday: new Date(1980, 6, 20),
});
console.log(jane.toJSON());
})();
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. ❤️