Tag Archives: MongoDB

Meteor – Insert Sample Data if the MongoDB is empty

Say we have a Meteor collection called Student.

model.js

Student = new Meteor.Collection('student');

 

So i would like to have some predefined students if the collection is emtpy. So i prepare the student.json in the private folder.

private/student.json

{
  "student":
  [
    { "_id": "1", "name": "Peter" },
    { "_id": "2", "name": "Jack" },
    { "_id": "3", "name": "Mary" },
    { "_id": "4", "name": "Sam" },
    { "_id": "5", "name": "Ann" },
  ]
}

Continue reading Meteor – Insert Sample Data if the MongoDB is empty

Meteor – High Network IO as it keeps polling MongoDB

I was working on a Meteor project which is connected to a mongoDB hosted on MongoLab. Since it is a sandbox plan, the oplog of the mongoDB instance is not available and in that case the Meteor will keep polling the mongoDB in around every 10 seconds. This causes a very high consumption on CPU and network bandwidth.

If you are running, Meteor 0.7.0 or above and your mongoDB has oplog enabled. You won’t experienced the problem.

Since the oplog is not available so the only workaround which i could think of is to unsubscribe the dataset. Here is a main.js which is executed when the app is loaded and when the user is idle for than 3 mins. Stop the subscription and that will stop polling the mongoDB.
Continue reading Meteor – High Network IO as it keeps polling MongoDB