How do you fetch all documents (including non-existent ancestor documents) in a Firebase collection?

后端 未结 2 1236
你的背包
你的背包 2020-12-22 09:12

I am trying to pull all the documents in the collection \'users\', but it only pulls \'fred\' and \'lisa\', and ignores all the italicized documents:

For this data:<

2条回答
  •  旧巷少年郎
    2020-12-22 09:33

    If you're trying to list all your registered users from Firebase auth, you can use the Firebase SDK function:

        function listAllUsers(nextPageToken) {
          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
              }
            })
            .catch(function(err) {
              console.log('Error listing users: ', error)
            });
        }
    
        listAllUsers();
    

    via http://firebase.google.com/docs/auth/admin/manage-users#list_all_users

提交回复
热议问题