My user model looks like:
var UserSchema = new Schema({
name: {
type: String,
unique: false
},
user_url:{
type: String
},
email: {
type: String,
lowercase: true
},
role: {
type: String,
default: 'individual'
},
plan: {
type: String,
default: 'basic'
},
password: String,
provider: String,
salt: String,
facebook: {},
twitter: {},
google: {},
github: {}
});
As you can see, I am trying to allow records with duplicate value in name
fields. However when trying to save it throws an error:
Unhandled rejection WriteError({"code":11000,"index":0,"errmsg":"E11000 duplicate key error index: dev.users.$name_1 dup key: { : \"ttp2\" }","op":{"user_url":"ttp2-0","salt":"LY59ooaz+8zZ4z8+dA/7dw==","provider":"local","name":"ttp2","email":"ttp2_1@example.com","password":"wEOc+pejEwfz/s11SWQiMpHxrkh7yLC+q+oa6Tad/QGvH+OFTBMAsVssBRvUKoRjE1dyJkZeh5UvCEJsgXAhNA==","_id":"56b5cc49b6bc872413f6c9fb","__v":0}})
What am I doing wrong?