amark / mongous

Simple MongoDB driver for Node.js with jQuery like syntax.
MIT License
246 stars 30 forks source link

Is remote connection possible? #35

Closed AJB99 closed 10 years ago

AJB99 commented 10 years ago

Hi there,

I'm new to Node and Mongo and mongous looks like exactly what I'd like to operate on my DB, except I can't figure out how to connect to it.

I'm hosting my DB with MongoHQ, how would I go about connecting to is using Mongous?

I've tried the following but it didn't work:

var $ = require("mongous").Mongous;
$().open("myhost.mongohq.com","12345").auth("myUserName","myPassword", function(reply){
    console.log("Connected to MongoHQ!");
});

Is this possible using Mongous?

Thanks!

amark commented 10 years ago

Hey, sorry it took me so long to reply - I was gone at a hackathon in SF.

You are very close! We definitely need to improve the remote connection code to make it easier (and to support connection URIs, which we currently don't). Here is the code that I have used in the past to connect to mongoHQ...

$("$cmd").open("myhost.mongohq.com", 12345);
$("$cmd").auth("myUserName", "myPassword", function(reply){
    console.log("Connected to MongoHQ!");
});

It is a little ugly, but it should work! Please let me know if this helped.

AJB99 commented 10 years ago

No worries at all amark, thanks for taking the time to answer. It's not ugly at all. Makes sense now that I see it written out. I'll give this a go. Thanks again for the great software!

will0321 commented 9 years ago

hi, 12345 is remote port?

amark commented 9 years ago

12345 is where the remote port goes, yes. The exact port number is up to whatever host you are using. Does that answer your question?