0
我正在開發一個應用程序,用戶可以預訂課程,我希望每個用戶只能烹飪一次課程。下面是我現在有,希望你們能幫助我:)只允許用戶發送一次輸入,MeteorJs
'click #book': function(e,tmpl){
if($.inArray(Session.get('userID'), Courses.find({_id: this._id}, {fields:{attendees: 1}})) === -1){
console.log('You have already booked this course');
}else{
Courses.update(this._id, {$push: {attendees: Session.get('userID')}});
Courses.update(this._id, {$inc: {numberPlaces: -1}});
console.log('You have booked the course');
}
}
正如你可以看到我記錄用戶的ID在收集並檢查他的身份證在已經存在的代碼那裏每當他試圖預訂課程。
謝謝!
謝謝!你的答案真的很有幫助! –