I have an existing mongo database in which ids (_id) are persisted as plain Strings.. This is sample data in Mongo DB:
{
\"_id\" : \"528bb0e2e4b0442f1479
I think the problem here is a wrong "_id" format and that is why Mongo cannot recognize any object with such id. It should looks like ObjectId("528bb0e2e4b0442f1479f1b4"), not plain String type.
{
"_id" : ObjectId("528bb0e2e4b0442f1479f1b4"),
"schoolId" : "URDLKYLFJXLWJGR193778316742298",
"surname" : "Lewis",
"admissionNumber" : "0347",
"firstName" : "Martins"
}
So if you have imported .json with existing data to mongo you need to change id:
"_id": {$oid:"528bb0e2e4b0442f1479f1b4"},
And it should be converted to correct format.
Hope it can help someone.