How to do validations before saving the edited data in mongoose?
For example, if sample.name already exists in the database, the user will receive a som
sample.name
For anybody falling on this old solution. There is a better way from the mongoose docs.
var s = new Schema({ name: { type: String, unique: true }}); s.path('name').index({ unique: true });