Use model.findById() to Search Your Database By _id

Use model.findById() to Search Your Database By _id
0

#1

For the mongodb/mongoose project: Use modle.findById() to Search Your Database By _id, I am runing into an error. Every time that I try to test my code, I get the Error: missing callback argument.
When I check the Glitch logs, it tells me: Missing done() argument

Here is my code for that section.


var findPersonById = (personId, done) => {
  Person.findById(Person.personId, (err, data) => err ? done(err) : done(null, data)); 
};

For the previous two challenges, I have used almost identical code and never ran into any problems. I am starting to wonder if it is a bug in the testing code.

**Here is a link to my project, if you want to look at the previous challenges’ code: https://glitch.com/edit/#!/shadow-sushi


#2

You need to remove the Person form your Person.personId.


#3

Hi sir,
Could you please explain why we need to remove the Person from Person.personId? I add Person to previous challenges and it all passed.


#4

Solution:
var findPersonById = (personId, done) => {
Person.findById(personId, (err, data) => err ? done(err) : done(null, data));
};