'this' is undefined in a Mongoose pre save hook [duplicate]
the issue is your arrow function uses lexical this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
change
userSchema.pre("save", (next) => { const currentDate = new Date this.updated_at = currentDate.now next()})
to
userSchema.pre("save", function (next) { const currentDate = new Date() this.updated_at = currentDate.now next()})