I have a mongoDB on an ec2 instance, I have been able to query a collection called Users successfully.
All of a sudden when I am trying to read the collection via id it returns null.
I logged into the instance and queried the database for users and there exists some orders.
I am using mongoose with the following query in my code
module.exports.readUser = function(id){
return new Promise((resolve,reject) => {
User.findOne({_id: id})
.exec()
.then(rem => {
resolve(rem);
})
.catch(error => {
reject(error.message)
})
})
}
When querying from the shell i use the following, and it works -
db.users.find({_id: ObjectId("5e89be482845434a7da45863")})
The above code should work once I am passing in a valid ObjectId String, but it fails across other collections as well.