I have a schema in Mongoose:
const member = new Schema({
_id: { type: String, required: true },
...
});
but when I use await MemberModel.findOne({ _id: req.params.userID });
in an express request handler, I get a CastError: Cast to ObjectId failed for value "MY_SECRET_VALUE" at path "_id" for model "Member".
I have set the _id type in the Schema to a String
so I don't understand why this is causing a problem. It should not be parsing the _id to an ObjectId - it should stay a String. I am trying to store a string in _id and then find all docs that match { _id: "MY_INPUT" }