supertokens-core
supertokens-core copied to clipboard
Basic batch operations with users
🚀 Feature
Right now there is no possibility to find multiple users, especially with their metadata.
Usecase
- I have user groups, stored in a separate DB
- 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
- All the user info (profile, avatar, etc) is stored in Metadata
- 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
-
Extend /users endpoint with query param that allows to specify filters like:
GET /users?filter[id]=usr1,usr2,usr3
or justGET /users?ids=usr1,usr2,usr3
-
Add additional query param
includeMetadata
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
Yeah, thanks, but as you already said it's not a good solution. Are there any plans on implementing this functionality?
@vyobukhov we can consider it. But it's probably not going to happen anytime soon as there are other priorities.
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.
- A request to get the users in the group and their user ids (stored in the group_users table).
- 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.