supertokens-core icon indicating copy to clipboard operation
supertokens-core copied to clipboard

Basic batch operations with users

Open vyobukhov opened this issue 2 years ago • 4 comments

🚀 Feature

Right now there is no possibility to find multiple users, especially with their metadata.

Usecase

  1. I have user groups, stored in a separate DB
  2. I store relations between group and users in group_users table. So I have no info about user, only about it's relation to specific group
  3. All the user info (profile, avatar, etc) is stored in Metadata
  4. I want to show all users in group with their name and avatar as a list

Right now the only way to achieve it is to do N requests to supertokens to retrieve every user by id and his metadata. While it is acceptable for 2-3 users. But becomes a disaster with 10+ users.

Implementation details

  1. Extend /users endpoint with query param that allows to specify filters like: GET /users?filter[id]=usr1,usr2,usr3 or just GET /users?ids=usr1,usr2,usr3

  2. Add additional query param includeMetadata

vyobukhov avatar Oct 19 '22 15:10 vyobukhov

Until this is implemented on our end, the way you can achieve this is to store info about the user in your own db by overriding the sign up API.

Then you can query your own db however you like.

PS: I know that my suggestion isn't a solution to the issue, but just putting it here in case it helps

rishabhpoddar avatar Oct 19 '22 15:10 rishabhpoddar

Yeah, thanks, but as you already said it's not a good solution. Are there any plans on implementing this functionality?

vyobukhov avatar Oct 19 '22 16:10 vyobukhov

@vyobukhov we can consider it. But it's probably not going to happen anytime soon as there are other priorities.

rishabhpoddar avatar Oct 20 '22 05:10 rishabhpoddar

Hi, I hope I'm not wrong, but we could implement pre-loading of data. This way instead of making a separate request for each user, we would only make two requests.

  1. A request to get the users in the group and their user ids (stored in the group_users table).
  2. A second request to retrieve the metadata of the users whose identifiers are in the list obtained in the first request.

Then the information obtained from both requests can be combined to build the list of users.

I hope my solution is helpful in addressing the issue.

DalemDev avatar Apr 11 '23 15:04 DalemDev