Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How does Meteor receive updates to the results of a MongoDB query?

How does Meteor receive updates to the results of a MongoDB query?

Problem

I asked a question a few months ago, to which Meteor seems to have the answer.

Which, if any, of the NoSQL databases can provide stream of *changes* to a query result set?

How does Meteor Receive Updates to the results of a MongoDB query?

Thanks,

Chris.

Problem courtesy of: chrisdew

Solution

From the docs:

  • On the Server, a collection with that name is created on a backend Mongo server. When you call methods on that collection on the server, they translate directly into normal Mongo operations.

  • On the client, a Minimongo instance is created. Minimongo is essentially an in-memory, non-persistent implementation of Mongo in pure JavaScript. It serves as a local cache that stores just the subset of the database that this client is working with. Queries on the client (find) are served directly out of this cache, without talking to the server.

When you write to the database on the client (insert, update, remove), the command is executed immediately on the client, and, simultaneously, it's shipped up to the server and executed there too. The livedata package is responsible for this.

That explains client to server

Server to client from what I can gather is the livedata and mongo-livedata packages.

https://github.com/meteor/meteor/tree/master/packages/mongo-livedata

https://github.com/meteor/meteor/tree/master/packages/livedata

Hope that helps.

Solution courtesy of: Loadx

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

How does Meteor receive updates to the results of a MongoDB query?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×