Alex Craft
Alex Craft

Reputation: 15386

How Meteor Framework partition data?

From what I know it seems that Meteor Framework stores part of data on the client. It's clear how to do it for personal todo list - because it's small and you can just copy everything.

But how it works in case of let's say Q&A site similar to this? The collection of questions are huge, you can't possibly copy it to the client. And you need to have filtering by tags and sorting by date and popularity.

How Meteor Framework handles such case? How it partition data? Does it make sense to use Meteor for such use case?

Upvotes: 1

Views: 127

Answers (1)

David Weldon
David Weldon

Reputation: 64342

Have a look at the meteor docs, in particular the publish and subscribe section. Here's a short example:

Imagine your database contains one million posts. But your client only needs something like:

  • the top 10 posts by popularity
  • the posts your friends made in the last hour
  • the posts for the group you are in

In other words, some subset of the larger collection. In order to get to that subset, the client starts a subscription. For example: Meteor.subscribe('popularPosts'). Then on the server, there will be a corresponding publish function like: Meteor.publish('popularPosts', function(){...}.

As the client moves around the app (changes routes), different subscriptions may be started and stopped.

The subset of documents are sent to the client and cached in memory in a mongodb-like store called minimongo. The client can then retrieve the documents as needed in order to render the page.

Upvotes: 2

Related Questions