mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
ReactiveMiniMongoIndex created, Javascript Index of MiniMongo Client Database
- I didn't find a solution to have indexes in MiniMongo on client. As i see / believe there isn't this feature yet in Meteor (v2.10). - I got this and many more results while looking for an solution: https://forums.meteor.com/t/adding-indexing-to-minimongo/9130/12 https://github.com/meteor/meteor-feature-requests/issues/66 So to speed up the MiniMongo i decided to create a own class for this, currently per query. Of course, this isn't the best solution, but works for now good.
This commit is contained in:
parent
726fd5d60d
commit
40a5422e75
2 changed files with 32 additions and 12 deletions
|
|
@ -1084,4 +1084,30 @@ ReactiveCache = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ReactiveCache };
|
// Client side little MiniMongo DB "Index"
|
||||||
|
ReactiveMiniMongoIndex = {
|
||||||
|
getSubTasksWithParentId(parentId, addSelect = {}, options) {
|
||||||
|
let ret = []
|
||||||
|
if (parentId) {
|
||||||
|
const select = {addSelect, options}
|
||||||
|
if (!this.__subTasksWithId) {
|
||||||
|
this.__subTasksWithId = new DataCache(_select => {
|
||||||
|
const __select = Jsons.parse(_select);
|
||||||
|
const _subTasks = ReactiveCache.getCards(
|
||||||
|
{ parentId: { $exists: true },
|
||||||
|
...__select.addSelect,
|
||||||
|
}, __select.options);
|
||||||
|
const _ret = _.groupBy(_subTasks, 'parentId')
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ret = this.__subTasksWithId.get(Jsons.stringify(select));
|
||||||
|
if (ret) {
|
||||||
|
ret = ret[parentId] || [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ReactiveCache, ReactiveMiniMongoIndex };
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { ReactiveCache } from '/imports/reactiveCache';
|
import { ReactiveCache, ReactiveMiniMongoIndex } from '/imports/reactiveCache';
|
||||||
import moment from 'moment/min/moment-with-locales';
|
import moment from 'moment/min/moment-with-locales';
|
||||||
import {
|
import {
|
||||||
ALLOWED_COLORS,
|
ALLOWED_COLORS,
|
||||||
|
|
@ -861,12 +861,9 @@ Cards.helpers({
|
||||||
},
|
},
|
||||||
|
|
||||||
subtasks() {
|
subtasks() {
|
||||||
const ret = ReactiveCache.getCards(
|
const ret = ReactiveMiniMongoIndex.getSubTasksWithParentId(this._id, {
|
||||||
{
|
|
||||||
parentId: this._id,
|
|
||||||
archived: false,
|
archived: false,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
sort: {
|
sort: {
|
||||||
sort: 1,
|
sort: 1,
|
||||||
},
|
},
|
||||||
|
|
@ -876,17 +873,14 @@ Cards.helpers({
|
||||||
},
|
},
|
||||||
|
|
||||||
subtasksFinished() {
|
subtasksFinished() {
|
||||||
const ret = ReactiveCache.getCards({
|
const ret = ReactiveMiniMongoIndex.getSubTasksWithParentId(this._id, {
|
||||||
parentId: this._id,
|
|
||||||
archived: true,
|
archived: true,
|
||||||
});
|
});
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
allSubtasks() {
|
allSubtasks() {
|
||||||
const ret = ReactiveCache.getCards({
|
const ret = ReactiveMiniMongoIndex.getSubTasksWithParentId(this._id);
|
||||||
parentId: this._id,
|
|
||||||
});
|
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue