Atlas: mongoDB what exactly are the tests doing?

Tell us what’s happening:
I’m not sure if I understand what is going on with this Challenge. The challenge completes with no error yet when I view the database on the Atlas: MongoDB there is nothing in the collection. There needs to be a better understanding of what exactly the tests are doing.

Your code so far
code is fine cause I’m using whats in the hint

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.

Challenge: Use model.find() to Search Your Database

Link to the challenge:

Welcome there.

If you look at the tests:

var findByName = require('./myApp.js').findPeopleByName;
router.post('/find-all-by-name', function(req, res, next) {
  var t = setTimeout(() => { next({message: 'timeout'}) }, timeout);
  Person.create(req.body, function(err, pers) {
    if(err) { return next(err) }
    findByName(pers.name, function(err, data) {
      clearTimeout(t);
      if(err) { return next(err) }
      if(!data) {
        console.log('Missing `done()` argument');
        return next({message: 'Missing callback argument'});
      }
      res.json(data);
      Person.remove().exec();
    });
  });
});

You can see that the Person is removed from the db, at the end of the function.

Hope this helps

1 Like

I just assumed that it wasn’t removing the collection. certainly explains why i don’t see it in the collection. Thanks for the help!