Import to Update Collection

I have the following code in client/main.js{
	'click .js-rate-image':function(event) {
		var rating = $(event.currentTarget).data("userrating");
		var image_id =;

How do update the collection on the server?

That’s it, you’re already updating the server :smiley: Through the magic of Meteor…

That is, assuming you still have the Insecure package installed, which is by it’s name obviously a bad idea and only intended for experimenting…

Otherwise you will have to set up allow rules for each collection, which will then allow you to call update() on the client, if it passes your security checks. This works well for small projects, but most people recommend instead moving your update() to a Meteor method (which you can run on both the client and server, to get the Optimistic UI feature of Meteor). I recommend going through the tutorials to learn about that, for example Discover Meteor or LevelUpTuts

Thanks for the quick reply.

When I reload the browser the stars rating disappears which I set before reloading.

Hmm, maybe you don’t have the Insecure package installed then?
In the browser console, does it say something like access denied? If so, the update is getting blocked by the security.

Nothing like access denied in the console and have insecure installed.

And on the server you have Images = new Mongo.Collection('images')?


Images = new Mongo.Collection("images");

Hmm, weird, it really ought to work then :thinking:
Try starting from scratch, create a fresh project and follow a tutorial maybe.

Can you check if autopublish is installed? @christocarr? Try:

meteor add autopublish

No no no no no. This is bad, don’t do it that way.


Give me 10 minutes on your app and I’ll have it all wrecked. But naw if you’re just starting out it’s cool to do it this way.

What you want to do is call a meteor method, like this:“posts.setImageRating”, $(event.currentTarget).data(“userrating”));

Inside of /server/main.js you’ll have a function there.

In this function you can validate the users, and run that same update code from the server.

The magic of Meteor is that this update ALSO happens on the client as well. So it appears instant for you, and rapid for others. “Real Timish”.