mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04: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 {
|
||||
ALLOWED_COLORS,
|
||||
|
@ -861,12 +861,9 @@ Cards.helpers({
|
|||
},
|
||||
|
||||
subtasks() {
|
||||
const ret = ReactiveCache.getCards(
|
||||
{
|
||||
parentId: this._id,
|
||||
const ret = ReactiveMiniMongoIndex.getSubTasksWithParentId(this._id, {
|
||||
archived: false,
|
||||
},
|
||||
{
|
||||
}, {
|
||||
sort: {
|
||||
sort: 1,
|
||||
},
|
||||
|
@ -876,17 +873,14 @@ Cards.helpers({
|
|||
},
|
||||
|
||||
subtasksFinished() {
|
||||
const ret = ReactiveCache.getCards({
|
||||
parentId: this._id,
|
||||
const ret = ReactiveMiniMongoIndex.getSubTasksWithParentId(this._id, {
|
||||
archived: true,
|
||||
});
|
||||
return ret;
|
||||
},
|
||||
|
||||
allSubtasks() {
|
||||
const ret = ReactiveCache.getCards({
|
||||
parentId: this._id,
|
||||
});
|
||||
const ret = ReactiveMiniMongoIndex.getSubTasksWithParentId(this._id);
|
||||
return ret;
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue