The problem is that i need two different data sets of one mongodb collection
//lib/col.js
Photos = new Meteor.Collection("photos");
lastPhotos = function() {
return Photos.find({},{sort:{created_time:-1},limit:4});
}
locationPhotos = function(location_id_var)
{
//**doesn't return data from server, goes to local cache**
return Photos.find({location_id: location_id_var});
}
//server
Meteor.publish("lastPhoto", function ()
{
return lastPhoto();
});
Meteor.publish("locationPhoto", function (location_id)
{
return locationPhoto(location_id);
});
//client
Meteor.subscribe("lastPhoto");
Meteor.subscribe("locationPhoto",{location_id:Session.get("location_id")});
The main problem that meteor merges two data sets of one collection.
At the templates I have two different presentations of one collection. Collection is big (6000 documents) and I can not send it to client wholly.
How can I get two different sets of documents of one collection without sending all documents to client?
You are on the right track. You need to wrap your
subscribein anautorunto have it dynamically change the server’spublishmethod.I hope this is helpful:
Javascript:
HTML: