Does Node.js Mongoose allow you to connect to a database via a user/password?
-
22-10-2019 - |
Question
How can I do that? Right now I can connect to the database, but it seems like only when no user is set...
It's version 1.0...but I can't find how to enter user/pass into the connection?
Solution
var db = mongoose.connect('mongodb://localhost/goaljuice');
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
http://www.tulek.org/2010/11/28/node-js-mongodb-mongoose/
http://www.mongodb.org/display/DOCS/Connections
In mongodb, you have to assign collections to users before they can access them.
db.addUser("theadmin", "anadminpassword")
http://www.mongodb.org/display/DOCS/Security+and+Authentication
HTH
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow