I have run into some issues when comparing ObjectIds using mongoDB and redis.
I store MongoDB documents as JSON strings in redis and use JSON.parse when retrieving from redis, but this converts the ObjectIds to strings and I am having a hard time converting them back.
I am using NodeJS with mongoose, and have tried the following:
mongoose.Types.ObjectId(string_of_objectid)
but I get the error
Argument passed in must be a single String of 12 bytes or a string of 24 hex characters in hex format
Make sure to trim
your string_of_objectid
.