【发布时间】:2019-05-21 20:38:42
【问题描述】:
我正在注册公司详细信息,并尝试验证该公司管理员的 电子邮件 ID 是否为 true。
所有细节都显示在回调 json 上,除了一个 ie; verified
这是我的架构详细信息:-
var adminSchema = new mongoose.Schema({
companyName : {
type: String,
required: "Company name can't be empty.",
required: false
},
companyID: {
type: String,
},
address : {
type: String,
required: "Address can't be empty.",
},
contactDetails : {
type: String,
required: "Company contact number can't be empty.",
},
admins: {
email : {
type: String,
required: "Email can't be empty.",
unique: true
},
password: {
type: String,
required: "Password name can't be empty."
},
firstName : {
type: String,
required: "First name can't be empty."
},
lastName : {
type: String,
required: "Last name can't be empty."
},
phoneNumber : {
type: String,
required: "Reqired for further contact. Can't be empty."
},
designation : {
type: String,
required: "Designation can't be empty."
},
verified: {
type: Boolean,
default: false
},
role: String,
emailResetTokenn: String,
emailExpires: Date,
saltSecret: String,//this is user for encryption and decryption of password
users:[]
}
});
在控制器中我正在做:-
module.exports.registerAdmin = (req, res, next) =>{
var admin = new Admin();
admin.companyName = req.body.companyName;
admin.address = req.body.address;
admin.contactDetails = req.body.contactDetails;
admin.admins = {
email : req.body.email,
password: req.body.password,
firstName : req.body.firstName,
lastName : req.body.lastName,
phoneNumber : req.body.phoneNumber,
designation : req.body.designation,
role : "admin",
users: []
};
当我运行路由 api 时,verified 详细信息未显示为 verified : false
结果:-
{
"admins": {
"email": "losefivex@mrmail.info",
"password": "$2a$10$pgkFZAfGwHkJ2e88/d2gUeWtjVdinxGmYGx5Euh69kgH95nCIUcNa",
"firstName": "hdsdsds",
"lastName": "Ghodsdsdsh",
"phoneNumber": "4544343",
"designation": "Software Engineer",
"role": "admin",
"users": [],
"emailResetTokenn": "c833599ab72255a957007b42ca1cb8fddd566d7474b8b2b92bc08252f60184fa",
"emailExpires": "2019-05-21T18:05:46.095Z",
"saltSecret": "$2a$10$pgkFZAfGwHkJ2e88/d2gUe"
},
"_id": "5ce3e99a896e8c3ff5665702",
"companyName": "Meta",
"address": "AUS",
"contactDetails": "54534454",
"companyID": "675521",
"__v": 0
}
为什么会丢失?
【问题讨论】:
标签: node.js express mongoose mongoose-schema