how to use mongoose unique validator code example
Example: mongoose unique validator
npm install --save mongoose-unique-validator
var mongoose = require('mongoose');
var uniqueValidator = require('mongoose-unique-validator');
var mySchema = mongoose.Schema(/* put your schema definition here */);
mySchema.plugin(uniqueValidator);