Update role
Modifies the data of an existing role
- Parameters
- Advanced call ?
Function UpdateRole(Val Connection, Val Name, Val Base = Undefined, Val PrivilegesArray = Undefined, Val RoleArray = Undefined, Val Parameters = Undefined) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | --dbc | String, Arbitrary | ✔ | Connection or connection string |
| Name | --name | String | ✔ | Role name |
| Base | --db | String | ✖ | Database name. Current database if not specified |
| PrivilegesArray | --prvl | Array of Structure | ✖ | Array of privileges. See GetRolePrivilegeStructure |
| RoleArray | --roles | Array Of Arbitrary | ✖ | Array of roles based on strings or structures specifying the database |
| Parameters | --params | Structure Of KeyAndValue | ✖ | Additional deletion parameters |
Returns
Map Of KeyAndValue - Operation result
| Parameter | Description |
|---|---|
| addin_mode | Manual selection of external component connection mode (for 1C): Isolated, NotIsolated |
| dontwait | Creates a background job and returns its data (for 1C and OneScript only) |
tip
The passed roles and privileges completely replace the current role data
Role can be defined in one of the following formats:
Structure: { role: "name", db: "database" }
String: role name
1C:Enterprise/OneScript code example
Address = "127.0.0.1:1234";
Login = "bayselonarrend";
Password = "12we...";
Base = "admin";
ConnectionParams = New Structure("authSource", "admin");
ConnectionString = OPI_MongoDB.GenerateConnectionString(Address, , Login, Password, ConnectionParams);
Connection = OPI_MongoDB.CreateConnection(ConnectionString);
RoleArray = New Array;
RoleArray.Add("read");
RoleArray.Add("userAdmin");
Resource = New Structure("db,collection", Base, "new_collection2");
Actions = New Array;
Actions.Add("find");
Actions.Add("insert");
Privilege = OPI_MongoDB.GetRolePrivilegeStructure(Resource, Actions);
PrivilegesArray = New Array;
PrivilegesArray.Add(Privilege);
RoleName = "newrole";
Result = OPI_MongoDB.UpdateRole(Connection, RoleName, Base, PrivilegesArray, RoleArray);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint mongodb UpdateRole \
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" \
--name "newrole" \
--db "admin" \
--prvl "[{'resource':{'db':'admin','collection':'new_collection2'},'actions':['find','insert']}]" \
--roles "['read','userAdmin']"
:: JSON data can also be passed as a path to a .json file
oint mongodb UpdateRole ^
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" ^
--name "newrole" ^
--db "admin" ^
--prvl "[{'resource':{'db':'admin','collection':'new_collection2'},'actions':['find','insert']}]" ^
--roles "['read','userAdmin']"
Result
{
"result": true,
"data": {
"ok": 1
}
}