Relative Content

Tag Archive for node.jsmongodbmongoosemongoose-schema

How to get the model name from a Mongoose duplicate error

In the application, I have defined two models. The first model is the movie model, and the second model is the user model. In the movie model, movie name is a unique field, and in the user model, email is a unique field. In the “duplicateKeyErrorHandler” function, the message is static, but I need a model name for a duplicate movie or duplicate email.