Replace mquandalle:collection-mutations with collection helpers

This commit is contained in:
Harry Adel 2026-01-21 19:22:54 +02:00
parent aca661583d
commit 94a3575e2c
35 changed files with 718 additions and 1321 deletions

View file

@ -90,29 +90,24 @@ ChecklistItems.before.insert((userId, doc) => {
}
});
// Mutations
ChecklistItems.mutations({
setTitle(title) {
return { $set: { title } };
ChecklistItems.helpers({
async setTitle(title) {
return await ChecklistItems.updateAsync(this._id, { $set: { title } });
},
check() {
return { $set: { isFinished: true } };
async check() {
return await ChecklistItems.updateAsync(this._id, { $set: { isFinished: true } });
},
uncheck() {
return { $set: { isFinished: false } };
async uncheck() {
return await ChecklistItems.updateAsync(this._id, { $set: { isFinished: false } });
},
toggleItem() {
return { $set: { isFinished: !this.isFinished } };
async toggleItem() {
return await ChecklistItems.updateAsync(this._id, { $set: { isFinished: !this.isFinished } });
},
move(checklistId, sortIndex) {
async move(checklistId, sortIndex) {
const cardId = ReactiveCache.getChecklist(checklistId).cardId;
const mutatedFields = {
cardId,
checklistId,
sort: sortIndex,
};
return { $set: mutatedFields };
return await ChecklistItems.updateAsync(this._id, {
$set: { cardId, checklistId, sort: sortIndex },
});
},
});