Skip to content

Commit 9d10732

Browse files
committed
fix: correct the this.isModified is not a function error
1 parent c0ce50a commit 9d10732

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

models/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const UserSchema = new Schema({
2323
});
2424

2525
/** Hash the password before saving it to the database*/
26-
UserSchema.pre('save', (next) => {
26+
UserSchema.pre('save', function(next) {
2727
/** this refers to the user passed as argument to the save method in /routes/user*/
2828
const user = this;
2929
/** only hash the password if it has been modified or its new */
@@ -58,4 +58,4 @@ UserSchema.methods.gravatar = (size) => {
5858
return 'https://gravatar.com/avatar/' + md5 + '?s=' + size + '&d=retro';
5959
};
6060
/** compiling our schema into a model object - a class that constructs documents in mongoose */
61-
module.exports = mongoose.model('User', UserSchema);
61+
module.exports = mongoose.model('User', UserSchema);

0 commit comments

Comments
 (0)