Answer the question
In order to leave comments, you need to log in
How to set unique parameter in MongooseJS?
Good afternoon!
I am doing authorization on the site, and due to inexperience I riveted the following scheme:
schema = new Schema({
local: {
/* Имя пользователя */
username: {
type: String,
required: true,
unique: true, /* <- не проверяется на уникальность */
index: true,
trim: true,
validate: validators.username
},
/* Имя пользователя в нижнем регистре*/
usernameLow: {
type: String,
unique: true, /* <- не проверяется на уникальность */
trim: true
},
/* Пароль */
hashedPassword: {
type: String
},
salt: {
type: String
}
},
vk: {
user_id: {
type: String
},
access_token: {
type: String
},
expires_in: {
type: Number
}
},
general: {
email: {
type: String,
required: false,
unique: true,
index: true,
trim: true,
validate: validators.email
},
role: {
type: String,
"default": "user"
},
created: {
type: Date,
"default": Date.now
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question