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
- Magic Link token automatically consumed
Hi, I'm using the Magic Link auth system with Appwrite Cloud and I'm running into huge issues getting users to log in successfully. About 9 times out of 10, th...
- Auth broken after update from 1.8.0 to 1...
So ive been having issues creating, deleting or updating users on my appwrite instance after i updated from 1.8.0 to version 1.9.0. When trying to create a user...
- Magic Link woes/noob
Magic Link is working; it sends the link to my email. But the link itself always leads to "Page Not Found. The page you're looking for doesn't exist". Clicking ...