我MemberProfiles和MemberPayments collections.The MemberProfile已经expiryDate场这是在insert.I设置为当前日期需要扩展设置一个触发添加到流星日期只要将MemberPayment添加到该MemberProfile中,就会显示一个唯一的MemberProfile。如何使用quickform
MemberProfiles = new Mongo.Collection('memberProfiles');
MemberProfileSchema = new SimpleSchema({
expiryDate: {
type: Date,
autoValue: function() {
return moment().toDate();
},
autoform: {
type: "hidden"
}
}
// to insert into Memb erProfiles
{{> quickForm collection="MemberProfiles" id="insertMemberProfileForm" type="insert" class="new-recipe-form"}}
//the code for MemberPayments collection
MemberPayments = new Mongo.Collection('memberPayments');
MemberPayments.before.insert(function (userId, doc) {
let memberProfile= MemberProfiles.direct.findOne({profile: doc.memberId});
MemberProfiles.update(doc.memberId, {
$set: {
expiryDate: moment().add(31, 'days');
,
}
}
)
});
我加入了所有必需的包,但仍这并不干活。我得到错误无法设置的特性“expiryDate”未定义
你可以编辑你的问题,并添加代码,你执行初始插入到MemberProfiles? – jordanwillis
好的,我正在使用quickForm插入到MemberProfiles中。 –
您是否也在使用collection2软件包? – jordanwillis