How do you remove a user from a team without knowing the MembershipId? The only way I found is to list all Memberships of the team and then loop over all of those to check the userId. This is so much performance overhead for such a simple task. Is there a better way? Edit: I'm speaking of server sdk here.
var teams = new Teams(client);
var allGroupMemberships = await teams.ListMemberships(groupId);
foreach (Membership membership in allGroupMemberships.Memberships)
{
if (membership.UserId != user.Id)
continue;
await teams.DeleteMembership(groupId, membership.Id);
}
What if you use listMemberships from Users?
https://appwrite.io/docs/references/cloud/server-nodejs/users#listMemberships
So you only will have search the teamId in the list of memberships of the user:
var users = new Users(client);
var teams = new Teams(client);
var userMemberships = await users.ListMemberships(userId);
foreach (Membership membership in userMemberships.memberships)
{
if (membership.teamId != teamId)
continue;
await teams.DeleteMembership(groupId, membership.Id);
}
I'm not sure about all code, but it should be something like that
Recommended threads
- Does 1.9.0 Self Hosted have MongoDB Atla...
I have been playing with the new 1.9.0 update and I am really excited for the MongoDB support. I wanted to ask though if at the current time Appwrite supports b...
- 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...
- significant increase in CPU usage with 1...
Hi, This is no big deal at all (as everything is working great so far), but I just saw that the update (from 1.8 to 1.9) consumes much more CPU than before (re...