-
Notifications
You must be signed in to change notification settings - Fork 69
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
Get opt.model.name undefined #1
Comments
Hi @jusefb thanks for the feedback. Did you enable the paper trail for that model? For example, if you have a user model, it should be enabled like this: 'use strict';
module.exports = function(sequelize, DataTypes) {
var user = sequelize.define('User', {
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true
}
}, {
classMethods: {
associate: function(models) {
// other associations can be defined here
}
}
});
user.hasPaperTrail();
return user;
}; |
Apologies for a late response. Yes I have enabled paper trail for the model in question. I was trying to understand where the opt.model.name is set but could not find it. |
When the before and after hooks are added, sequelize automatically sets the right values for |
Here is the debug output: afterHook called |
Thanks, that's really helpful :) It looks like
Is there a reason for doings this? Sequelize should be able to handle it by itself. |
In my application I load the models automatically from the model directory (this was based on a sequelize example)
So I am not sure what sets the plural and singular names. I assume it is the sequilize import function. Is there a workaround I could use you think? |
If you want a really quick (and a dirty) fix for it you can do this:
that should resolve it in your case I think while I look into a better solution today. Let me know if that works! |
Will close this for now, please reopen it if it is still an issue. |
I had/have the same issue, using the same example sequelize code to load in different model files. |
seems like it would be easy enough for the official code to check if instance['$modelOptions'].name.singular or opt.model.name is what is available. |
Hi,
I have tried to use the library but unfortunately I am getting an error at the step when the revision gets built. It seem that opt.model.name property is undefined in my case. Is there a specific format in which the model has to be constructed for this to work? Here is the portion of code that throws the error [TypeError: Cannot read property 'name' of undefined] in lib.js line 272
Thank you in advance for you help
The text was updated successfully, but these errors were encountered: