Trying to use a remote mongodb hosted in MongoLab. My code to do that below:
if (Meteor.isClient) {
Meteor.subscribe('allData')
Data = new Mongo.Collection("myData");
console.log(Data.find().count());
}
if (Meteor.isServer) {
var database = new MongoInternals.RemoteCollectionDriver("mongodb://username:password@xxx.mongolab.com:00000/db");
Data = new Mongo.Collection("myData", { _driver: database });
console.log(Data.find().count());
Meteor.publish('allData', function () {
return Data.find();
})
}
The server code seems to work since the console logs out the correct .count()
, but the client only logs 0
for the .count()
. Will using a remote mongodb only work on the server, and won’t be accessible in the client code?
Thanks!