When Sequelize saves an instance to a database (eg. MySQL) it automatically adds an "id" field at the end (auto-incremented also). I've read the articles and the documentation but I couldn't find any way to disable it.
Thank you.
It appears from the source that if you define an attribute as a 'primaryKey', the DAO interface will remove the default 'id' field in preference to your own primary key.
See line 1140 or thereabouts in dao-factory.js where:
var addDefaultAttributes = function() {
var self = this
, defaultAttributes = {
id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true
}
}
if (this.hasPrimaryKeys) {
defaultAttributes = {}
}
... etc. ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With