> For the complete documentation index, see [llms.txt](https://skyslit.gitbook.io/magicjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://skyslit.gitbook.io/magicjs/api-references/backend/utils/findallrolesbyuser.md).

# findAllRolesByUser()

This function is designed to retrieve all the roles assigned to a specific user within a system. This function is useful for querying and obtaining information about the roles associated with a particular user.

> Here is an Example:

```typescript
import { createBackendFunction, utils } from "@magicjs.dev/backend"
 
export default createBackendFunction(
  async function (userId) {
 
   const roles =  await utils.findAllRolesByUser(String(userId))
    return { message: "Roles fetched", roles }
  },
)
```

[Click here to refer GitHub.](https://github.com/skyslit/magicjs.dev/blob/main/packages/backend/src/utils.ts#L52)
