嵌入式文档实例化的麻烦

时间:2015-01-03 21:38:37

标签: angularjs node.js mongoose mean-stack

使用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'}
});

0 个答案:

没有答案