Publish a big number of documents


#1

Hi Guys

Im using meteor 1.1 and im trying to publish a big number of documents (like 4000 [each document with 5-10 properties, string a-Z all]).
I want to show those documents in a table but when i do it… it takes like 10 to 20 seconds to show them.

is this a good time ? i could improve it ? how ?

Im using:

  • Reactive Table

Thanks,
Cristian


#2

You need to be able to page through your subscription on the server side so that your data loads instantly and keeps loading incrementally.

Reactive table’s server side paging is at beta stage right not (as far as I know) but https://github.com/aldeed/meteor-tabular/ is built out of box for large datasets specifically.


#3

@serkandurusoy thanks! i will take a look at it. Looks cool!!


#4

@serkandurusoy

Ive been trying to make Tabular (test) work like this:

test.js

if(Meteor.isServer){
  
  Books = new Mongo.Collection("Books");

  var vares = {
    titulo: 'test',
    autor: 'test',
    copias: 'test'
  };
  
  Books.insert(vares);

  console.log("docs:"+Books.find().count());

}


if(Meteor.isClient){

  TabularTables = {};

  Template.registerHelper('TabularTables', TabularTables);
  

  TabularTables.Books = new Tabular.Table({
    name: "BookList",
    collection: Books,
    columns: [
    {data: "titulo", title: "Title"},
    {data: "autor", title: "Author"},
    {data: "copias", title: "Copies Available"}
    ]
  });

}

and test.html

<head>
  <title>tabular</title>
</head>

<body>
  <h1>Test x1!</h1>
  <div class="col-lg-12">
  {{> hello}}
  </div>
</body>

<template name="hello">
  {{> tabular table=TabularTables.Books class="table"}}
</template>

i keep getting:

Error: You must pass Tabular.Table instance as the table attribute

Im doing something Wrong ?

Thanks,
Cristian


#5

Disclaimer: I have never used this package. However, looking at the example on the repo and comparing with your code, the most obvious difference is that you have split your code between client and server within Meteor.isClient and Meteor.isServer blocks.

In the repo, all code is common except for:

Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);

(There is also a tmpl: reference as a cell content, but I’m discounting that as you’re not doing that)


#7

Yep i tried like the git example but still having the same error…

First i though it was my project but… i isolated the test to a new project, same error.


#8

Can you post your latest code that contains your latest changes after comments from @robfallows


#9

Yes, here is my Test.js

if(Meteor.isServer){
  Books = new Mongo.Collection("Books");
  var vares = {
    titulo: 'test',
    autor: 'test',
    copias: 'test'
  };
  Books.insert(vares);
}

TabularTables = {};
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
TabularTables.Books = new Tabular.Table({
  name: "BookList",
  collection: Books,
  columns: [
  {data: "titulo", title: "Title"},
  {data: "autor", title: "Author"},
  {data: "copias", title: "Copies Available"}
  ]
});

#10

Here’s what worked for me:

Books = new Mongo.Collection("Books");
var vares = {
  titulo: 'test',
  autor: 'test',
  copias: 'test'
};
Books.insert(vares);

TabularTables = {};
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
TabularTables.Books = new Tabular.Table({
  name: "BookList",
  collection: Books,
  columns: [
  {data: "titulo", title: "Title"},
  {data: "autor", title: "Author"},
  {data: "copias", title: "Copies Available"}
  ]
});

I took out the Meteor.isServer block.

EDIT: The inserting of the “test” data is not ideally situated in this example, and normally would go on the server in a Meteor.startup() callback. I think this is maybe what you were trying to do?

I would create a server folder and add a preload.js file with something like:

Meteor.startup(function() {
  var vares = {
    titulo: 'test',
    autor: 'test',
    copias: 'test'
  };
  Books.insert(vares);
});

#11

@robfallows beat me to it!

It seems he’s done that quite a few times lately :slight_smile:


#12

:smile:

And having now used the package I find I like it and will probably use it for real. Win, win!


#13

It worked @robfallows, @serkandurusoy. Thanks!