find by _id with Mongoose

Because this query finds the doc in the shell:

db.getCollection('stories').find({_id:'572f16439c0d3ffe0bc084a4'})

That means that the type of _id in the document is actually a string, not an ObjectId like Mongoose is expecting.

To find that doc using Mongoose, you’d have to define _id in the schema for Story as:

_id: { type: String }

Leave a Comment

tech