I have a scenario where I need to fetch the last login data for all users in Auth0, based on email addresses stored in MongoDB. Currently, I am using the following approach:
await axios.request({
method: 'GET',
url: `https://${process.env.AUTH0_DOMAIN}/api/v2/users-by-email`,
params: { email: user.email },
headers: { authorization: `Bearer ${accessToken}` }
});
However, with 10K users, I need to retrieve the last login data for each email address efficiently. What is the best optimized and scalable solution for this scenario, considering the need to handle a large number of users? Ideally, the solution should support pagination with a minimum limit of 500.