skip to Main Content

Mongodb – Getting error node BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer value:Array

I am working on a node js project where I am getting the following error : CastError: Cast to ObjectId failed for value "[ [ '63e8e6e8b8a285d68b1fbd0c', '63e9951ded54221a516fc622' ] ]" (type Array) at path "labels" because of "BSONTypeError" at ObjectId.cast (/var/www/html/IssueTracker/node_modules/mongoose/lib/schema/objectid.js:248:11)…

VIEW QUESTION

Mongodb – How to handle mongoose errors globaly

As for now, I'm using mongoose middleware to handle Mongoose specific errors (validation, cast, ....). I'm using the following code in all of my schemas: schema.post('save', handleValidationError); schema.post('findOneAndUpdate', handleValidationError); schema.post(['findOne', 'deleteOne'], handleCastError); Is there anyway to make this global in…

VIEW QUESTION
Back To Top
Search