Skip to content

Instantly share code, notes, and snippets.

@alex2006hw
Created October 7, 2015 15:10
Show Gist options
  • Save alex2006hw/c93d8c387f2891e36357 to your computer and use it in GitHub Desktop.
Save alex2006hw/c93d8c387f2891e36357 to your computer and use it in GitHub Desktop.
// http://stackoverflow.com/questions/28787886/meteor-database-connection
if (Meteor.isServer) {
var database = new MongoInternals.RemoteCollectionDriver("mongodb://127.0.0.1:3001/meteor");
Boxes = new Mongo.Collection("boxes", { _driver: database });
Meteor.publish('boxes', function() {
return Boxes.find();
});
}
if (Meteor.isClient) {
Boxes = new Mongo.Collection("boxes");
Meteor.subscribe('boxes');
Template.homeCanvasTpl.helpers({
boxes: function () {
return Boxes.find({});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment