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

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

#1

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.


#2

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.