Q:

Model.save() is bugged?

I'm trying to pass freecodecamp test which require to submit a name and save it to collection. However, everytime i pressed submit in my form, there is this lengthy warning message in the console : 
(node:20679) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
This is my route code : 
app.post('/api/exercise/new-user/', (req, res) => {
  const {username} = req.body;
  if(username===''){
    res.send('Name must not empty');
  }else{
    const aNewTrainee = new PersonExcer({name:username});
    aNewTrainee.save().then(aTrainee => {
            res.status(200).json(aTrainee);
        })
        .catch(err => {
            res.status(400).send('adding new todo failed');
        });
  }  
})

And since if i tried to query the document collection after save, there is no result, then that can only mean the save() call did not work : 
//This has no result
app.get('/api/exercise/users', (req, res)=>{
  PersonExcer.find(function(err, docs) {
    if (err) {
            console.log(err);
        } else {
            res.json(docs);
        }
  });
  //This has no result
})

Please have a look at the complete code here (edit: link removed).

A:

I've been try your code and it's working fine, please update/upgrade your mongoose to the latest version.
You can use this command line below to check which packages have newer versions available:
npm outdate

For upgrade your mongoose, you can use this command line:
npm install mongoose@latest --save

For update, you can use this command line:
npm update mongoose

I hope it can help you.

