Post Mongoose模型没有使用Passport.js进行“保存”的方法

Post Mongoose模型没有使用Passport.js进行“保存”的方法,post,mongoose,passport.js,Post,Mongoose,Passport.js,在我的应用程序中,用户进行身份验证,然后进行测验。我想将测验结果保存到用户模式。当我运行以下操作时,正确的信息会打印到控制台,但保存时会出现错误: //Error printing to console: User.save(function(err){ ^ TypeError: Object function model(doc, fields, skipId) { if (!(this instanceof model)) return new model(doc

在我的应用程序中,用户进行身份验证,然后进行测验。我想将测验结果保存到用户模式。当我运行以下操作时,正确的信息会打印到控制台,但保存时会出现错误:

//Error printing to console:
User.save(function(err){             ^
TypeError: Object function model(doc, fields, skipId) {
if (!(this instanceof model))
  return new model(doc, fields, skipId);
Model.call(this, doc, fields, skipId);
} has no method 'save'

//update the user with the kitten Type
app.post('/api/kittens', isLoggedIn, function (req, res, done) {

    console.log(req.user.kittenType); //an empty set by default
    console.log(req.body.kittenType); //the quiz result 


   User.findOne({ 'kittenType': req.user.kittenType}, function(err, user) {
    if(err) 
        return done(err);

    if(user) {
        User.kittenType = req.body.kittenType;
        User.save(function(err){
            if(!err){
                console.log('yay');
            }
            else {
                console.log(err);
            }
        });
        console.log(User.kittenType);
    }
}); 
});

var userSchema = mongoose.Schema({

    user            : {
        type: mongoose.Schema.ObjectId,
        ref: 'User'
    },

     kittenType   : String,
     local            : {
        email        : String,
        password     : String,
        petname      : String,
        path         : String,  
},


});

问题在于资本化:

应为user.kittenType和user.save,而不是user.save