1
我很新的Node.js,我开始一个新的Web应用程序只是为了研究。 所以,我使用Mongoose.js,这是我的模型:建模node.js与猫鼬
党模式:
var PartySchema = new Schema({
created: {
type: Date,
default: Date.now
},
title: {
type: String,
default: '',
trim: true
},
createdBy: {
type: Schema.ObjectId,
ref: 'User'
},
invitations: [{
type: Schema.ObjectId,
ref: 'Invitation'
}]
});
的邀请模式:
var InvitationSchema = new Schema({
party: {
type: Schema.ObjectId,
ref: 'Party'
}
});
好吧, 所以我写了一个测试像这样的情况下,假设其他变量(方)被正确初始化:
invitation = new Invitation({
party: party,
content: 'come to this awesome party'
});
当我通过这个变量邀请的方法是这样的:
return Party.sendInvitation(invitation, function(err, invitation) {
should.exist(invitation);
should.not.exist(err);
done();
});
访问sendInvitation方法内invitation.party是这样的:
invitation.party[525439f929cf32be02000003]
作为似乎,我无法通过invitation.party
导航。 我怎样才能达到这个invitation.party.title
?
我感谢任何帮助!