我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