How to return a Mongo sub-Collection based on geolocation?
say
Products =
[
{
"name": "London TV",
"location": "London"
},
{
"name": "New York TV",
"location": "New York"
},
{
"name": "Default TV",
"location": "SomeWhere"
}
]
if (location==London) {
//Serve location==London sub-collection as well as Default collection
Meteor.publish('london-collection', function () {
return Products.find({location: 'London'});
});
} else if (location==New York) {
//Serve location of New York sub-collection as well as Default collection
Meteor.publish('newyork-collection', function () {
return Products.find({location: 'New York'});
});
}
This is like using userID, but instead using another variable like geolocation to return sub-collections of MongodB thanks
Tried:
filterCollectionBasedOnLocation: function (cLoc) {
var future = new Future();
if (cLoc == 'London') {
future.return(
Products.find({
$and: [
{'location': 'London'},
{'location': 'Default'},
],
}),
);
} else if (cLoc == 'Liverpool') { etc