The mongoDB collection contains the following data
db.stack.find() { "_id" : "8GieRu" }
_id is not a single line of 12 bytes,
According to the MongoDB document [ObjectID] [1], id (string) - it can be a 24-byte hexadecimal string, a 12-byte binary string, or a number.
Using Mongoose, this collection is available using this Json.
{"_id" : new mongoose.Types.ObjectId("8GieRu")}
and produces the following error
/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/objectid.js:35 throw new Error("Argument passed in must be a single String of 12 bytes or ^ Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters at new ObjectID (/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/objectid.js:35:11) [1]: http://mongodb.imtqy.com/node-mongodb-native/api-bson-generated/objectid.html
Mongoose strictly checks ObjectId of fixed length, how can I pass Object_id using mongoose with given length
anish
source share