ReactiveMiniMongoIndex, added getChecklistsWithCardId

This commit is contained in:
Martin Filser 2023-03-03 20:25:52 +01:00
parent 40a5422e75
commit f80ecded0a
2 changed files with 23 additions and 1 deletions

View file

@ -1107,6 +1107,28 @@ ReactiveMiniMongoIndex = {
}
}
return ret;
},
getChecklistsWithCardId(cardId, addSelect = {}, options) {
let ret = []
if (cardId) {
const select = {addSelect, options}
if (!this.__checklistsWithId) {
this.__checklistsWithId = new DataCache(_select => {
const __select = Jsons.parse(_select);
const _checklists = ReactiveCache.getChecklists(
{ cardId: { $exists: true },
...__select.addSelect,
}, __select.options);
const _ret = _.groupBy(_checklists, 'cardId')
return _ret;
});
}
ret = this.__checklistsWithId.get(Jsons.stringify(select));
if (ret) {
ret = ret[cardId] || [];
}
}
return ret;
}
}

View file

@ -809,7 +809,7 @@ Cards.helpers({
},
checklists() {
const ret = ReactiveCache.getChecklists({ cardId: this.getRealId() }, { sort: { sort: 1 } });
const ret = ReactiveMiniMongoIndex.getChecklistsWithCardId(this.getRealId(), {}, { sort: { sort: 1 } });
return ret;
},