Skip to main content

getRoleKey()

Last updated 12/09/2024

Example One

The following code will get the role with the name of Member and migrate the users to use this role except admin and public assigned roles.

Updating users roles
function MigrateRoles(five: Five, context: any, result: FiveError) : FiveError {
const iRoleKey = five.getRoleKey('Member');
const updateResults = five.executeQuery(`UPDATE iUser SET iRoleKey = ? WHERE UserID <> 'admin' AND UserID <> 'public'`, 0, iRoleKey);
if (updateResults.isOk() === false) {
return five.createError(updateResults);
}

return five.success(result, 'Migration completed');
}