Back

[SOLVED] How to get a user's team(s)?

  • 0
  • Teams
  • Accounts
  • General
  • Web
kathelia.dokgu
6 Aug, 2023, 15:05

I'm looking at the documentation https://appwrite.io/docs/client/teams?sdk=web-default#teamsList which is very close to what I need, but I want to be able to get a list of the teams a user belongs to, basically I want to be able to supply it with a user ID and it will give me a list of the teams for that user:

TypeScript
const promise = teams.list(userId);

Is this possible?

TL;DR
There is a solution for getting a user's team(s). You can use the Users API on the server-side by creating a function in your appwrite console that utilizes the `users.listMemberships('[USER_ID]')` resource. This will allow you to retrieve a list of teams for a specific user. Make sure to check the Users API documentation and the guide to Appwrite Functions for more details. The reference for executing functions from the client-side is also provided.
safwan
6 Aug, 2023, 15:29

Not with the client SDK. You could however use the Users API to do exactly this on the server-side.

You'll have to create a function in your appwrite console that uses the users.listMemberships('[USER_ID]') resource to do this.

Users API: https://appwrite.io/docs/server/users?sdk=nodejs-default Reference for users.listMemberships: https://appwrite.io/docs/server/users?sdk=nodejs-default#usersListMemberships Guide to Appwrite Functions: https://appwrite.io/docs/functions Reference for executing functions from the client-side: https://appwrite.io/docs/client/functions

kathelia.dokgu
6 Aug, 2023, 15:47

Thank you! That works!

safwan
6 Aug, 2023, 16:04

Will be marking this as solved, but feel free to come back and ask any questions if you face problems 😁

safwan
6 Aug, 2023, 16:05

[SOLVED] How to get a user's team(s)?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more