Mongoose: Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters

Created on 14 Nov 2016  路  3Comments  路  Source: Automattic/mongoose

I have an application running, and I had some problems when I make a find in a string (even though it is an ObjectId), I already tried to convert the String to ObjectId with mongoose.Types.ObjectId(' 53cb6b9b4f4ddef1ad47f943 ') (example) and Even then I can not get the return and it returns me the following error:

Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters

Also returns me:

this.id.charCodeAt is not a function

Has anyone had this problem yet?

Most helpful comment

Try trimming the spaces in your string

mongoose.Types.ObjectId ('53cb6b9b4f4ddef1ad47f943')

All 3 comments

Try trimming the spaces in your string

mongoose.Types.ObjectId ('53cb6b9b4f4ddef1ad47f943')

Sorry, it was typing error ... neat =)

hi i m bikash

Was this page helpful?
0 / 5 - 0 ratings