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

Allow Advanced Querying with UserMetadata Recipe

Open Dan6erbond opened this issue 2 years ago • 2 comments

🚀 Feature

The UserMetadata recipe is great for storying core user data, but it really makes it hard to query and group users for purposes such as analytics and listing specific users. Especially as I'm currently using the recipe to store groups which isn't implemented in the UserRoles recipe (see #468) I will end up often fetching all the users only to read the group their assigned to.

Since PostgreSQL and MongoDB should both support querying JSON fields, with the JSON field in PostgreSQL and native support in MongoDB, I propose that querying is implemented by the SuperTokens Core API, and for compatibility with MySQL filters are applied manually (with performance loss).

Further info on querying JSON in PostgreSQL: How to Query a JSON Column in PostgreSQL - PopSQL

The filters and sorting options should follow simple RESTful design patterns using query params and as the UserMetadata recipe does seem to be designed around storying key:value pairs without too much nesting, I don't see the need to support deep queries with dot-notation or similar, just top-level queries would be sufficient supporting all the JSON datatypes.

Implementation details

(Please outline any details about how this feature would e implemented. If you don't know, you can just skip this section.)

Dan6erbond avatar Jul 11 '22 07:07 Dan6erbond

That's a must-have feature since metadata is the only way to store anything about user. All databases already support JSON column type, we can just a make a simple fallback to text for old MySQL (yes, search there will be shitty or slow, but it's better than nothing)

vyobukhov avatar Apr 13 '23 16:04 vyobukhov

Fair enough @vyobukhov . We will add this to our roadmap. But in the meantime, you can store user info in your own db against the user ID that we issue.

rishabhpoddar avatar Apr 14 '23 05:04 rishabhpoddar