Connect to remote MongoDB using Meteor

I apologize in advance for the fact that I do not agree with my terminology and understanding with Meteor / Mongo, I just started to learn and develop with it.

I am trying to connect a local meteor application to a remote mongodb that is hosted elsewhere.

My code is as follows:

Bills = new Mongo.Collection("bills"); if (Meteor.isClient) { Meteor.subscribe("bills"); // This code only runs on the client Template.body.helpers({ documentContent: function () { return Bills.find(); } }); Template.documentBody.helpers({ documentContent: function () { var thingy = Bills.find(); console.log(thingy); return Bills.find({_id: "784576346gf874"}); } }); } 

I connected to the database through the shell using the following:

 $ MONGO_URL="mongodb://mysite.net:27017/legislation" meteor 

In my browser, I get no errors, and within my defined template I see [Object]. The console shows a local mini-set, but does not return any of my documents from the signed collection.

I suppose I ask; if you were connecting to remote MongoDB in your local application, how would you do it?

Thank you for taking the time to read, any helpful tips are welcome.

+6
source share
1 answer

Rex If you do not see errors in the output in the browser or on the console on which the server is running, then you can configure OK. This is exactly how I do it.

Run meteor list in the server directory and find insecure and autopublish

You must understand these two packages. They are designed for rapid prototyping. If they are present, continue to dig into MongoDB and the connection.

I recommend Robomongo for viewing documents directly in MongoDB.

If they are missing, you need to publish the data (get it from the server to the client) and provide it (letting the customers only change their data).

I recommend these two packages for this.

reywood:publish-composite ongoworks:security

If you have not read the introduction to the book of meteors , it is really worth the time. I have been developing and studying meteors for some time lately. It was priceless.

+1
source

Source: https://habr.com/ru/post/978676/


All Articles