[英]How to create DB users in mongodb using mongoose
I can create users from mongo shell using createUser() function. 我可以使用createUser()函数从mongo shell创建用户。 but i have a requirement that i need to create users from GUI(using nodej,express).Im using mongoose for multiple connections to db.
但我有一个要求,我需要从GUI创建用户(使用nodej,express)。我使用猫鼬对数据库进行多个连接。 i cant see any functions in mongoose.
我看不到猫鼬的任何功能。 is there any functions or packages that supports features like createUser, delete user like this.
是否有任何支持诸如createUser之类的功能或软件包,像这样删除用户。
connect using db = mongoose.mongo.MongoClient('mongodb://'+username+':'+password+'@localhost/dbtoconnect, function(err, db){});
使用
db = mongoose.mongo.MongoClient('mongodb://'+username+':'+password+'@localhost/dbtoconnect, function(err, db){});
using db object get admin access first. 使用db对象首先获取管理员访问权限。 Then you can use admin collection and authenticate using admin username and password using
admin_db.authenticate('adminusername', 'password');
然后,您可以使用admin收集,并使用
admin_db.authenticate('adminusername', 'password');
使用admin用户名和密码进行身份验证admin_db.authenticate('adminusername', 'password');
using addUser
function you can add the users 使用
addUser
函数可以添加用户
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.