开发者

Does Node.js Mongoose allow you to connect to a database via a user/password?

开发者 https://www.devze.com 2023-02-28 19:19 出处:网络
How can I do that? Right now I can connect to the database, but i开发者_运维技巧t seems like only when no user is set...

How can I do that? Right now I can connect to the database, but i开发者_运维技巧t seems like only when no user is set...

http://mongoosejs.com/

It's version 1.0...but I can't find how to enter user/pass into the connection?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消