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?
@Steven 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
- how to set up smtp setting
Hello @everyone, I am able to create session after sign up successfully but I am not able to get the email on my gmail. It seems the smtp setting is not set up ...
- Email Authentication gives a 'missing sc...
Hi, i am currently creating an app with appwrite but I have an issue. I added verification via email and password to it, which works just fine. But now I want t...
- Oauth sessions give wrong or incomplete ...
The attached screenshot shows the supposed session information using Google auth from an Android phone. Why are the indicated values either empty or wrong?