Skip to content

Instantly share code, notes, and snippets.

@mattn9x
Last active July 8, 2017 19:19
Show Gist options
  • Save mattn9x/b8f9e92f525747c87ced3ad7e9e83480 to your computer and use it in GitHub Desktop.
Save mattn9x/b8f9e92f525747c87ced3ad7e9e83480 to your computer and use it in GitHub Desktop.
Custom user role in mongodb
use admin
var role = {
'role' : 'develop',
'privileges' : [
{
'resource': {'db' : 'company', 'collection' : 'users'},
'actions': ['find']
}
],
'roles' : [
{'role' : 'readWrite', 'db' : 'phone_solution'}
]
}
db.createRole( role );
var user = {
'user' : 'admin2',
'pwd' : 'admin123abc',
roles : [
{'role' : 'develop', 'db' : 'admin'}
]
}
db.createUser(user);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment