mongodb getting TypeError: is not a function

Published on Author Code Father

You have got some things wrong.

Something like this (User refers to your schema):

var user = new User(); =; =;
user.password = req.body.password; = req.body.user_bio;, result) {
    console.log('User Created');});

should work better. Instead of passing a new object (which obviously doesn’t contain the save method), you are now creating a new object from the schema, setting the parameters, and then save it.

You then also have to change to this:

User.pre('save', function(next) {
    bcrypt.genSalt(10, function(err, salt) {
        bcrypt.hash(this.password, salt, function(err, hash) {
            this.password = hash;

This is a hook, which is called every time before the user gets saved.