-
Notifications
You must be signed in to change notification settings - Fork 286
Sequelize v6 compatibility? #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
+1 |
3 similar comments
+1 |
+1 |
+1 |
Apparently @next allow sequelize v6 compatibility #787 |
Most likely this pull request added support for v6 compatibility #807. |
We tried to work with sequelize-typescript@next (2.0-beta) with Nest-Js, it works with sequelize v6.1. @RobinBuschmann we can help you to release v6.3.5 compatibility @lukashroch @divlo 🤷🏼♂️ |
As discussed in #871. |
Can you show us the « Invitation » model ? |
Looks like you're using old v5 class declaration. You must update all models to reflect v6 changes. |
Yes, am I doing something wrong ? @goalia |
Thanks @lukashroch! It solves the problem. 👍 |
I was testing the latest beta import { Sequelize, Optional, Model, DataTypes } from 'sequelize';
interface PersonAttributes {
id: number;
name: string;
country?: string;
}
interface PersonCreationAttributes extends Optional<PersonAttributes, 'country'> {}
class Person extends Model<PersonAttributes, PersonCreationAttributes> implements PersonAttributes {
id!: number;
name!: string;
country?: string;
}
(async () => {
const sequelize = new Sequelize({
dialect: 'mysql',
host: 'localhost',
port: 3306,
database: 'testdb',
username: 'admin',
password: 'admin',
logQueryParameters: true,
logging: true,
});
await sequelize.authenticate();
Person.init({
id: {
type: DataTypes.INTEGER,
primaryKey: true,
},
name: {
type: DataTypes.STRING,
allowNull: false
},
country: {
type: DataTypes.STRING,
allowNull: true
}
}, {
tableName: 'Person',
sequelize
});
await sequelize.sync();
const p = new Person({
id: 1,
name: 'Ken'
});
await p.save();
const persons = await Person.findAll();
console.log(persons);
await sequelize.close();
})(); The following does not work, using import { Optional } from 'sequelize';
import { Sequelize, Model } from "sequelize-typescript";
interface PersonAttributes {
id: number;
name: string;
country?: string;
}
interface PersonCreationAttributes extends Optional<PersonAttributes, 'country'> {}
class Person extends Model<PersonAttributes, PersonCreationAttributes> implements PersonAttributes {
id!: number;
name!: string;
country?: string;
}
(async () => {
const sequelize = new Sequelize({
dialect: 'mysql',
host: 'localhost',
port: 3306,
database: 'testdb',
username: 'admin',
password: 'admin',
logQueryParameters: true,
logging: true,
});
await sequelize.authenticate();
await sequelize.addModels([Person]); // <-- compiler complains
await sequelize.sync();
const p = new Person({
id: 1,
name: 'Ken'
});
await p.save();
const persons = await Person.findAll();
console.log(persons);
await sequelize.close();
})(); Am I missing something? |
@goalia thanks but this solution doesn't provide type checking on model creation, which I guess is the main reason to extends |
@spinlud sequelize/sequelize#11820 This PR was created a long time ago. I'm not sure what to do :/ |
@antonstjernquist it looks like that that PR was left unmerged, this one has been merged instead sequelize/sequelize#12405. There is this other PR #868 which seems trying to fix issue about Model generics signature |
|
Is sequelize v6 compatibility still in beta? Any ETA?
The text was updated successfully, but these errors were encountered: