Skip to content

Instantly share code, notes, and snippets.

@aanchirinah
Last active July 28, 2018 12:28
Show Gist options
  • Save aanchirinah/ab2191334c4c3cef2ade5eac184e9a32 to your computer and use it in GitHub Desktop.
Save aanchirinah/ab2191334c4c3cef2ade5eac184e9a32 to your computer and use it in GitHub Desktop.
Generating User with Sequelize CLI
module.exports = function(sequelize, DataTypes) {
var User = sequelize.define('User', {
firstName: DataTypes.STRING,
lastName: DataTypes.STRING,
email: DataTypes.STRING,
password: DataTypes.STRING,
isVerified: DataTypes.BOOLEAN
}, {
classMethods: {
associate: function(models) {
User.hasOne(models.VerificationToken, {
as: 'verificationtoken',
foreignKey: 'userId',
foreignKeyConstraint: true,
});
}
}
});
return User;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment