Is there a way to filter team membership by role? I can't seem to find any information regarding it in the docs. There's listMemberships but it doesn't seem to provide a way to specify roles. Any help will be greatly appreciated.
you'd want to Query for it, so
const result = await teams.listMemberships(
'<TEAM_ID>', // teamId
[
Query.contains("roles", "your_role"),
], // queries (optional)
'<SEARCH>' // search (optional)
);
Already tried that it doesn't work. I get attribute not found.
roles?
Yes
I assume you tried the search attribute too?
Yes I did. It returns empty response.
Sometimes the attributes aren't exactly as they are written, it might be labels in the backend
I know for me, I pull the memberships of the team and then filter, but that's because my teams won't be that big, so I just store the value client-side in a local store
My teams can have a great number of members so it's not feasible for me to fetch all the team members then filter
Guess I'd have to use a collection to keep track of the teamId+userId+roles I'm interested in filtering. 🤦♂️ I'd prefer not to go with this approach so I'd wait for a bit if anyone has any idea.
what's the usecase you have?
<@462046107556511744> what's the best approach here?
For my use case every team has an owner, moderators and members. In an admin dashboard, there's a page where I have to show only the moderators for each team and perform some actions.
The docs tell you want attributes you can filter on: https://appwrite.io/docs/references/cloud/server-nodejs/teams#listMemberships
it would be best to create a feature request and make sure to include this use case in the github issue
Yes I checked, filtering by roles is not possible atm
Noted, thanks
I did this, but I pulled them all and filtered locally, it's insecure technically if you view the network request, but it shouldn't be an issue overall, it just might take a second if they have > 1000 members
Recommended threads
- Courtesy limit reset for non-profit migr...
Hi Team! I'm the architect for a 501(c)(3) non-profit project (Aaria's Blue Elephant) and we just hit our Free plan Database Read limit (currently at 164%). Th...
- RBAC design question
Hi, I am trying to create RBAC so we will have multiple orgs in the app each org will have 3 roles (admin, member and read only) what is the best way to go ab...
- Team invite - 500 error - no email
When executing ```dart await _repository.teams.createMembership( teamId: event.listId, roles: ['member'], email: event.email, url: 'xxxx', ); ``` I se...