The @Unique decorator is used to make an attribute unique, it is a shortcut for setting the unique option of the Attribute decorator. Learn more about unique constraints in our documentation.

This makes "firstName" unique

class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
@Attribute(DataTypes.STRING)
@Unique
declare firstName: string;
}

This creates a composite unique on columns "firstName" and "lastName"

class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
@Attribute(DataTypes.STRING)
@Unique('firstName-lastName')
declare firstName: string;

@Attribute(DataTypes.STRING)
@Unique('firstName-lastName')
declare lastName: string;
}