Maslosoft Mangan Logo Maslosoft Mangan Documentation
MongoDB Object Persister

Edit

Users management

Adding users to MongoDB

Users can be added by invoking command createUser(), which takes as an argument User model which has properties compatible with mongodb params for createUser.

Define it's $user (username), $pwd (password), and $roles, then pass it to createUser().

Property $roles can be defined as array of roles or as object of type Roles, which can be used to simplify defining roles.

Example of creating user:

$user = new User;
$user->user = 'webuser';
$user->pwd = 'admin123';
$user->roles = new Roles('myDatabase', ['readWrite']);

Then save it with createUser():

(new Command)->createUser($user);

Removing users

To remove user invoke dropUser(), with it's username as an argument.

Example of removing user:

(new Command)->dropUser('webuser');