MongoDB and Mongoose - Use model.findById() to Search Your Database By _id

I can not pass this,what is the problem and what do I need to write to make it correct?
Code:

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

Hi Barayturk

My first reply here in freecodecamp :roll_eyes:

Person is a Model, it doesn’t have a property personId.

Maybe this could work:
Person.findById(personId, (err, data) => err ? done(err) : done(null, data));

Regards.

1 Like

Thank you @miguelangeltorresfp!

1 Like