使用Mongooose / Node.JS.我试图在用户注册时创建用户对象。我想要做的是能够访问CandidateProfile部分并在用户输入该数据后再填充它。有人可以建议我需要采取的下一步措施。我尝试了很多选项,但似乎无法创建链接到用户文档的CandidateProfile文档。
var CandidateProfileSchema = new Schema({
//Info
name: String,
email: {type: String, lowercase: true},
mobile: Number,
isITProfessional: Boolean,
isMobileVerified: Boolean,
isEmailVerified: Boolean,
isRegistrationCompleted: Boolean,
active: Boolean,
// MORE FIELDS
});
var UserSchema = new Schema({
name: String,
email: { type: String, lowercase: true },
role: {
type: String,
default: 'user'
},
hashedPassword: String,
provider: String,
salt: String,
candidateProfile: {type: mongoose.Schema.Types.ObjectId, ref: 'CandidateProfileSchema'}
});