code: async function ensureRoleRoles (roleId, roleIds, roleMembershipModel) {
    const existingRoles = await roleMembershipModel.find({
      where: {
        roleId: { equals: roleId },
        memberType: { equals: 'role' }
      }
    })
    for (const { roleId, memberId } of existingRoles) {
      await roleMembershipModel.destroyById([roleId, 'role', memberId])
    }
  
    const updates = roleIds
      .filter(isNotNull)
      .filter(isString)
      .filter(isNotBuiltIn)
      .map(inheritedId =>
        ensureRoles(inheritedId, [ roleId ], 'role', roleMembershipModel)
      )
    return Promise.all(updates)
  }
docs: clearUserRoles