简体   繁体   中英

How to create DB users in mongodb using mongoose

I can create users from mongo shell using createUser() function. but i have a requirement that i need to create users from GUI(using nodej,express).Im using mongoose for multiple connections to db. i cant see any functions in mongoose. is there any functions or packages that supports features like createUser, delete user like this.

connect using db = mongoose.mongo.MongoClient('mongodb://'+username+':'+passwor‌​d+'@localhost/dbtoco‌​nnect, function(err, db){});

using db object get admin access first. Then you can use admin collection and authenticate using admin username and password using admin_db.authenticate('adminusername', 'password'); using addUser function you can add the users

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM