Following is my user schema in user.js model -
user
user.js
var userSchema = new mongoose.Schema({ local: { name: { type: String },
Change the collection name if it already exists in the database, it will show an error. And if you given any property as unique the same error will occur.