You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From mongoose version 6 onwards, MongoError has been changed to MongoServerError. I think mongoose-beautiful-unique-validation plugin is not working for mongoose >= 6 version due to this change, as in the isUniqueError function just err.name === 'BulkWriteError' || err.name === 'MongoError' is checked.
I suggest adding MongoServerError to this condition. In case of any doubt, I leave the error log using mongoose 7.0.4:
MongoServerError: E11000 duplicate key error collection: followupusers index: email_1 dup key: { email: "[email protected]" } at node_modules\mongodb\lib\operations\insert.js:50:33 at node_modules\mongodb\lib\cmap\connection_pool.js:327:25 at node_modules\mongodb\lib\sdam\server.js:207:17 at handleOperationResult (node_modules\mongodb\lib\sdam\server.js:323:20) at Connection.onMessage (node_modules\mongodb\lib\cmap\connection.js:213:9) at MessageStream.<anonymous> (node_modules\mongodb\lib\cmap\connection.js:59:60) at MessageStream.emit (node:events:512:28) at processIncomingData (node_modules\mongodb\lib\cmap\message_stream.js:124:16) at MessageStream._write (node_modules\mongodb\lib\cmap\message_stream.js:33:9) at writeOrBuffer (node:internal/streams/writable:392:12) { index: 0, code: 11000, keyPattern: { email: 1 }, keyValue: { email: '[email protected]' }, [Symbol(errorLabels)]: Set(0) {} }
Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hello,
From mongoose version 6 onwards, MongoError has been changed to MongoServerError. I think mongoose-beautiful-unique-validation plugin is not working for mongoose >= 6 version due to this change, as in the
isUniqueError
function justerr.name === 'BulkWriteError' || err.name === 'MongoError'
is checked.I suggest adding
MongoServerError
to this condition. In case of any doubt, I leave the error log using mongoose 7.0.4:MongoServerError: E11000 duplicate key error collection: followupusers index: email_1 dup key: { email: "[email protected]" } at node_modules\mongodb\lib\operations\insert.js:50:33 at node_modules\mongodb\lib\cmap\connection_pool.js:327:25 at node_modules\mongodb\lib\sdam\server.js:207:17 at handleOperationResult (node_modules\mongodb\lib\sdam\server.js:323:20) at Connection.onMessage (node_modules\mongodb\lib\cmap\connection.js:213:9) at MessageStream.<anonymous> (node_modules\mongodb\lib\cmap\connection.js:59:60) at MessageStream.emit (node:events:512:28) at processIncomingData (node_modules\mongodb\lib\cmap\message_stream.js:124:16) at MessageStream._write (node_modules\mongodb\lib\cmap\message_stream.js:33:9) at writeOrBuffer (node:internal/streams/writable:392:12) { index: 0, code: 11000, keyPattern: { email: 1 }, keyValue: { email: '[email protected]' }, [Symbol(errorLabels)]: Set(0) {} }
Thanks in advance.
The text was updated successfully, but these errors were encountered: