sequelize-7

Comprehensive reference for Sequelize v7 (alpha), the TypeScript-first Node.js ORM supporting PostgreSQL, MySQL, MariaDB, SQLite, MSSQL, DB2, and Snowflake. Use when working with @sequelize/core package: defining models with decorators, writing database queries (CRUD, associations, raw SQL), managing transactions, hooks, connection pools, setting up associations, or migrating from Sequelize v6 to v7.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "sequelize-7" with this command: npx skills add totophe/skills/totophe-skills-sequelize-7

Sequelize v7 — Claude Skill

Key Differences from Sequelize v6

  • Package renamed: sequelize@sequelize/core
  • Dialects are separate packages (e.g., @sequelize/postgres, @sequelize/sqlite3)
  • Decorator-based model definitions (recommended over Model.init())
  • Constructor only accepts a single options object (no URL string as first arg)
  • dialectOptions removed — settings go in top-level options
  • CLS transactions enabled by default (no manual setup needed)
  • Default association names are now camelCase (userId not UserId)
  • sequelize.transaction() only creates managed transactions; use sequelize.startUnmanagedTransaction() for unmanaged
  • JSON null vs SQL NULL distinction: inserting null into JSON stores JSON 'null', not SQL NULL
  • Minimum: Node >= 18, TypeScript >= 5.0

Skill Files

FileContents
getting-started.mdInstallation, connection, TypeScript setup, logging
models.mdModel definitions, data types, decorators, timestamps, naming, validation, indexes
querying.mdCRUD operations, operators, WHERE clauses, raw SQL, JSON querying, subqueries
associations.mdHasOne, HasMany, BelongsTo, BelongsToMany, eager loading
advanced.mdTransactions, hooks, scopes, connection pool, paranoid models, optimistic locking, read replication, migrations

Quick Reference — Common Patterns

Minimal Model (TypeScript + Decorators)

import { Model, InferAttributes, InferCreationAttributes, CreationOptional, DataTypes } from '@sequelize/core';
import { Attribute, PrimaryKey, AutoIncrement, NotNull } from '@sequelize/core/decorators-legacy';

export class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
  @Attribute(DataTypes.INTEGER)
  @PrimaryKey
  @AutoIncrement
  declare id: CreationOptional<number>;

  @Attribute(DataTypes.STRING)
  @NotNull
  declare name: string;

  @Attribute(DataTypes.STRING)
  declare email: string | null;

  declare createdAt: CreationOptional<Date>;
  declare updatedAt: CreationOptional<Date>;
}

Initialize Sequelize

import { Sequelize } from '@sequelize/core';
import { PostgresDialect } from '@sequelize/postgres';

const sequelize = new Sequelize({
  dialect: PostgresDialect,
  host: 'localhost',
  port: 5432,
  database: 'mydb',
  user: 'user',
  password: 'pass',
  models: [User],
});

Basic CRUD

// Create
const user = await User.create({ name: 'Alice' });

// Read
const users = await User.findAll({ where: { name: 'Alice' } });
const one = await User.findByPk(1);

// Update
await user.update({ name: 'Bob' });
await User.update({ name: 'Bob' }, { where: { id: 1 } });

// Delete
await user.destroy();
await User.destroy({ where: { id: 1 } });

Association with Eager Loading

const posts = await Post.findAll({
  include: ['comments'],
  where: { authorId: 1 },
});

Managed Transaction

const result = await sequelize.transaction(async () => {
  const user = await User.create({ name: 'Alice' });
  await Profile.create({ userId: user.id, bio: 'Hello' });
  return user;
});

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

skill-creation

No summary provided by upstream source.

Repository SourceNeeds Review
General

umzug

No summary provided by upstream source.

Repository SourceNeeds Review
Web3

azure-rbac

Use the 'azure__documentation' tool to find the minimal role definition that matches the desired permissions the user wants to assign to an identity. If no built-in role matches the desired permissions, use the 'azure__extension_cli_generate' tool to create a custom role definition with the desired permissions. Then use the 'azure__extension_cli_generate' tool to generate the CLI commands needed to assign that role to the identity. Finally, use the 'azure__bicepschema' and 'azure__get_azure_bestpractices' tools to provide a Bicep code snippet for adding the role assignment. If user is asking about role necessary to set access, refer to Prerequisites for Granting Roles down below:

Repository SourceNeeds Review
155135.2K
microsoft