I’m working on arabic-russian dictionary. It’s my first app with Meteor. I’ve learned docs and watched level up tutorial, and some other sources, but still have a question about subscription.
My dictionary collection at now have 37297 documents, with nested fields, arrays of objects about 10MB.
Main page of app is search page, when I type word, then in helper I split it and add some regex patterns of Arabic morphology. And It’s work. But on first opening of app it load so long… about 20sec. What should I do? Can I subscribe in helper on especial docs after there was found in MongoDb?
I tried use “template level subscription” in find page. But after that Single pages from results don’t opens. Now I use just subscribe on all articles .
That is how it works now:
Template.Search.onCreated(function(){
/* var self = this;
self.autorun(function(){
self.subscribe("articles");
});*/
Meteor.subscribe('articles');
});
Template.Search.events({
'submit'(event, instance){
event.preventDefault();
const searchFor = event.target.searchFor.value;
FlowRouter.go('search', { searchFor });
},
});
Template.Search.helpers({
result() {
const instance = Template.instance();
const searchFor = FlowRouter.getParam('searchFor');
const regexp_template = arabicWordToRegExPatern(searchFor);
const articles = Articles.find(
{
"words.word" : regexp_template
},
{
limit: 50
});
const count = articles.count();
return { articles, count }
},
searchFor() {
return FlowRouter.getParam('searchFor');
}
});
What are works fine?
ArticleSingle is base template. Further, on it ArticlePage.html:
<template name="ArticlePage">
<div class="container article-page">
{{#if Template.subscriptionsReady}}
{{> ArticleSingle article}}
{{else}}
<p>Loading...</p>
{{/if}}
</div>
</template>
ArticlePage.js :
Template.ArticlePage.onCreated(function(){
var self = this;
var id = FlowRouter.getParam('id');
self.autorun(function(){
self.subscribe("articleSingle", id);
});
//Meteor.subscribe('articles');
});
Template.ArticlePage.helpers({
article() {
const id = FlowRouter.getParam('id');
return Articles.findOne({'_id': id});
},
});
Also I use aldeed:Autoform and it seems working good in duet with ArticlePage And ArticleSingle.
But this delay about 20sec on first run Search-page is so long. I suppose it’s because of subscription on too many data from MongoDB, and I did’t find yet how to fix it