Sequelize instance methods not working : <p>I am trying to use Sequelize's instance method to validate a password on login attempt.
I have defined the User model as :</p>

<pre><code>var User = sequelize.define('User',{
    id:{
          type:DataTypes.BIGINT,
          autoIncrement: true,
          allowNull: false,
          primaryKey:true
        },
    username:{
          type:DataTypes.STRING,
          unique:true
        },
    password:{
          type: DataTypes.STRING
        },
    ...
  },
  {
    classMethods:{
        associate:function(models){
        ...
        }
      }
  },
  {
    instanceMethods:{
        validatePassword:function(password){
          return bcrypt.compareSync(password, this.password);
        }
      }
  }
);
  return User;
}
</code></pre>

<p>In my login route I do the following :</p>

<ul>
<li>1) Retrieve username &amp; password from request body </li>
<li>2) Check if username exists in database </li>
<li>3) If user exists, get user object and compare sent password with hashed password in database using validatePassword method.</li>
</ul>

<p>Here is the relevant code</p>

<pre><code>var username = req.body.username || "";
var password = req.body.password || "";
models.User.findOne({ where: {username: username} }).
then(
    function(user) {
     if(user){
      console.log(user.validatePassword(password));
     }
 ....
</code></pre>

<p>Each time I try to login I get the following error</p>

<pre><code>[TypeError: user.validatePassword is not a function]
</code></pre>

<p>What am I doing wrong? </p>
