mongoose getting `TypeError: user.save is not a function` - what is wrong

You will need to also define a model, change your schema definition to this:

var UserSchema = new mongoose.Schema({
name:String,
username:{type:String, required:true, index:{unique:true}},
password:{type:String, required:true, select:false}
})
var User = mongoose.model('User', UserSchema);

Then you should be good to go :)


first create model from Schema :

 var UserModel = mongoose.model('User', User);

then create object out of User model

 var user = new UserModel(req.body)

then call

 user.save(function(){})

check documentation http://mongoosejs.com/docs/api.html#model_Model-save