1

I'm new to using MongoDB and would appreciate some help in replicating the following command in my NodeJS application.

mongo --host dds-xxxx.mongodb.rds.aliyuncs.com:3717 -u root -p password --authenticationDatabase admin

I need to be able to connect with these credentials from Node, preferably but not necessarily using the MongoJS library. Any assistance would be greatly appreciated!

Thanks again.

Nodal
  • 353
  • 2
  • 14

1 Answers1

1

You can use the following:

mongoose.connect('mongodb://username:password@host:port/database

In your case:

 mongoose.connect('mongodb://root:password@dds-xxxx.mongodb.rds.aliyuncs.com:3717/admin

You can find more at: http://mongoosejs.com/docs/connections.html

deChristo
  • 1,860
  • 2
  • 17
  • 29