diff --git a/src/sscce-sequelize-7.ts b/src/sscce-sequelize-7.ts index 4a5757700..3b03ffff5 100644 --- a/src/sscce-sequelize-7.ts +++ b/src/sscce-sequelize-7.ts @@ -1,7 +1,13 @@ -import { DataTypes, Model } from '@sequelize/core'; +import { CreationOptional, DataTypes, Model } from "@sequelize/core"; +import { + Attribute, + AutoIncrement, + NotNull, + PrimaryKey, +} from "@sequelize/core/decorators-legacy"; import { createSequelize7Instance } from '../dev/create-sequelize-instance'; -import { expect } from 'chai'; -import sinon from 'sinon'; +import { expect } from "chai"; +import sinon from "sinon"; // if your issue is dialect specific, remove the dialects you don't need to test on. export const testingOnDialects = new Set(['mssql', 'sqlite', 'mysql', 'mariadb', 'postgres', 'postgres-native']); @@ -30,6 +36,20 @@ export async function run() { modelName: 'Foo', }); + // You can also use the new decorators model definition + class Bar extends Model { + @Attribute(DataTypes.INTEGER) + @PrimaryKey + @AutoIncrement + declare id: CreationOptional; + + @Attribute(DataTypes.TEXT) + @NotNull + declare name: string; + } + + sequelize.addModels([Bar]); + // You can use sinon and chai assertions directly in your SSCCE. const spy = sinon.spy(); sequelize.afterBulkSync(() => spy()); diff --git a/tsconfig.json b/tsconfig.json index ee5b40e91..7625b0b76 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,8 +5,9 @@ ], "compilerOptions": { "target": "es2021", - "module": "CommonJS", - "moduleResolution": "Node", + "module": "nodenext", + "experimentalDecorators": true, + "moduleResolution": "nodenext", "esModuleInterop": true, "resolveJsonModule": true, "newLine": "lf",