Reputation: 887
What I want to achieve here is, I should be able to pass phone numbers in an array and result should contain the user results matching with the phone number contained in the array.
Retrieving all the users are working just fine but I am not able to find out how to filter the results.
exports.listUsers = functions.https.onRequest(async(req, res) => {
// List batch of users, 1000 at a time.
const nextPageToken = req.query.token
const mobileNumbers = req.query.phoneNumbers
admin.auth().listUsers(1000, nextPageToken)
.then(function(listUsersResult) {
listUsersResult.users.forEach(function(userRecord) {
console.log('user', userRecord.toJSON());
});
if (listUsersResult.pageToken) {
// List next batch of users.
listAllUsers(listUsersResult.pageToken);
}
return res.send(listUsersResult);
})
.catch(function(error) {
console.log('Error listing users:', error);
});
});
Upvotes: 2
Views: 1780
Reputation: 24134
The Firebase Admin SDK provides APIs for retrieving individual users by phone number and by email. However, there is no batch retrieval API for filtering/querying all users by attributes such as phoneNumber
or email
.
If filtering a large user base is a common operation for your app, then you can improve performance by storing users in a separate database.
Upvotes: 1