Skip to content

Make pagination of users across auth recipes easier to implement #259

@rishabhpoddar

Description

@rishabhpoddar

Right now, each auth recipe (emailpassword, thirdparty..) has their own isolated users table. While paginating in them in isolation works fine, there is a problem when paginating in a recipe that combines the two - we have to manually create pagination tokens that work across both the recipes. This is complex, annoying and error prone

Core change

  • To fix this, we create one users table that can be shared across all auth recipes. This users table contains:

    userId: string,
    timeJoined: number,
    createdByRecipe: string (recipeId)
    

    Using the above, pagination across users created from multiple recipes becomes very easy.

    The API for this can take:

    limit: number, // limit is max 500
    nextPaginationToken?: string,
    includeRecipeIds?: string[]
    timeJoinedOrder?: "ASC" | "DESC"
    

    includeRecipeIds can be used for pagination across only certain recipes. If this is missing, we paginate across all recipes.

  • We need to create a global count API as well:

    includeRecipeIds?: string[]
    
  • Deprecate current getCount and pagination functions


Backend driver change

  • We need to add one recipe independent pagination function
  • We need to have one recipe independent get count function as well
  • Deprecate current getCount and pagination functions
  • Remove count and pagination functions from recipe implementation

Docs changes

  • Change in recipe interface.
  • API change for getCount and pagination functions in docs
  • Adding values for includeRecipeIds in each recipe docs.
  • Change in value of limit

TODO:

  • CDI change
  • DB changes
    • Do we need an index on recipe_id?
    • Is our query optimal?
      • we should filter based on timeJoined first and then based on recipeId
    • sqlite
    • postgresql
    • mysql
    • mongodb
  • API creation
    • count
    • pagination
  • Testing core
    • count
    • pagination
  • Backend SDK changes
  • Testing backend SDK
  • Docs:
    • Add to CDI open API spec
    • Add link in pagination docs (where it says TODO)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions