Javascript Firestore从expo环境呼叫后返回元数据

Javascript Firestore从expo环境呼叫后返回元数据,javascript,firebase,react-native,google-cloud-firestore,expo,Javascript,Firebase,React Native,Google Cloud Firestore,Expo,大家好,我是新来的。我使用expo env的firebase包将firebase连接到我的项目。auth和adding db工作得很好,但是当我试图从firestore获取数据时,我得到了大量元数据,无法解析它 这是我的呼叫功能 const getUserData = async () => { const uid = await AuthUser.getUser(); try { const data = await

大家好,我是新来的。我使用expo env的firebase包将firebase连接到我的项目。auth和adding db工作得很好,但是当我试图从firestore获取数据时,我得到了大量元数据,无法解析它

这是我的呼叫功能

const getUserData = async () => {
        const uid = await AuthUser.getUser();
        try {       
            const data = await firebase.firestore().collection('users').get();
            data.docs.forEach(doc => {
                console.log(doc.data())
            });
        } catch (error) {
            console.log("error while getting user details", error)
        }
    }; 
这就是我得到的结果

Array [
  Zu {
    "_": vu {
      "Hf": Ku {
        "firestore": Qu {
          "INTERNAL": Object {
            "delete": [Function _delete],
          },
          "Id": qu {},
          "_": tu {
            "A_": FirebaseAppImpl {
              "automaticDataCollectionEnabled_": false,
              "container": ComponentContainer {
                "name": "[DEFAULT]",
                "providers": Map {
                  "app" => Provider {
                    "component": Component {
                      "instanceFactory": [Function anonymous],
                      "instantiationMode": "LAZY",
                      "multipleInstances": false,
                      "name": "app",
                      "serviceProps": Object {},
                      "type": "PUBLIC",
                    },
                    "container": [Circular],
                    "instances": Map {
                      "[DEFAULT]" => [Circular],
                    },
                    "instancesDeferred": Map {},
                    "name": "app",
                  },
                  "platform-logger" => Provider {
                    "component": Component {
                      "instanceFactory": [Function anonymous],
                      "instantiationMode": "LAZY",
                      "multipleInstances": false,
                      "name": "platform-logger",
                      "serviceProps": Object {},
                      "type": "PRIVATE",
                    },
                    "container": [Circular],
                    "instances": Map {},
                    "instancesDeferred": Map {},
                    "name": "platform-logger",
                  },
                  "fire-core-rn-version" => Provider {
                    "component": Component {
                      "instanceFactory": [Function anonymous],
                      "instantiationMode": "LAZY",
                      "multipleInstances": false,
                      "name": "fire-core-rn-version",
                      "serviceProps": Object {},
                      "type": "VERSION",
                    },
                    "container": [Circular],
                    "instances": Map {},
                    "instancesDeferred": Map {},
                    "name": "fire-core-rn-version",
                  },
                  "fire-js-version" => Provider {
                    "component": Component {
                      "instanceFactory": [Function anonymous],
                      "instantiationMode": "LAZY",
                      "multipleInstances": false,
                      "name": "fire-js-version",
                      "serviceProps": Object {},
                      "type": "VERSION",
                    },
                    "container": [Circular],
                    "instances": Map {},
                    "instancesDeferred": Map {},
                    "name": "fire-js-version",
                  },
                  "auth" => Provider {
                    "component": Object {
                      "instanceFactory": [Function instanceFactory],
                      "instantiationMode": "LAZY",
                      "multipleInstances": false,
                      "name": "auth",
                      "serviceProps": Object {
                        "ActionCodeInfo": Object {
                          "Operation": Object {
                            "EMAIL_SIGNIN": "EMAIL_SIGNIN",
                            "PASSWORD_RESET": "PASSWORD_RESET",
                            "RECOVER_EMAIL": "RECOVER_EMAIL",
                            "REVERT_SECOND_FACTOR_ADDITION": "REVERT_SECOND_FACTOR_ADDITION",
                            "VERIFY_AND_CHANGE_EMAIL": "VERIFY_AND_CHANGE_EMAIL",
                            "VERIFY_EMAIL": "VERIFY_EMAIL",
                          },
                        },
                        "ActionCodeURL": [Function d],
                        "Auth": [Function En],
                        "AuthCredential": [Function Bg],
                        "EmailAuthProvider": [Function d],
                        "Error": [Function t],
                        "FacebookAuthProvider": [Function d],
                        "GithubAuthProvider": [Function d],
                        "GoogleAuthProvider": [Function d],
                        "OAuthProvider": [Function d],
                        "PhoneAuthProvider": [Function d],
                        "PhoneMultiFactorGenerator": [Function d],
                        "RecaptchaVerifier": [Function d],
                        "SAMLAuthProvider": [Function d],
                        "TwitterAuthProvider": [Function d],
                      },
                      "type": "PUBLIC",
                    },
                    "container": [Circular],
                    "instances": Map {
                      "[DEFAULT]" => Object {
                        "apiKey": "xxxx",
                        "appName": "[DEFAULT]",
                        "authDomain": "xxxx",
                        "currentUser": Object {
                          "apiKey": "xxxx",
                          "appName": "[DEFAULT]",
                          "authDomain": "xxxx",
                          "createdAt": "xxxx",
                          "displayName": null,
                          "email": "sayanc20002@gmail.com",
                          "emailVerified": false,
                          "isAnonymous": false,
                          "lastLoginAt": "1620559912736",
                          "multiFactor": Object {
                            "enrolledFactors": Array [],
                          },
                          "phoneNumber": null,
                          "photoURL": null,
                          "providerData": Array [
                            Object {
                              "displayName": null,
                              "email": "sayanc20002@gmail.com",
                              "phoneNumber": null,
                              "photoURL": null,
                              "providerId": "password",
                              "uid": "sayanc20002@gmail.com",
                            },
                          ],
                          "redirectEventId": null,
                          "stsTokenManager": Object {
                            "accessToken": "xxxx",
                            "apiKey": "xxxx",
                            "expirationTime": 1620563512726,
                            "refreshToken": "xxxx",
                          },
                          "tenantId": null,
                          "uid": "uoGEBWjWHMfXhBL4dVodHAiHr7d2",
                        },
                      },
                    },
                    "instancesDeferred": Map {},
                    "name": "auth",
                  },
                  "auth-internal" => Provider {
                    "component": Object {
                      "instanceFactory": [Function instanceFactory],
                      "instantiationMode": "LAZY",
                      "multipleInstances": false,
                      "name": "auth-internal",
                      "type": "PRIVATE",
                    },
                    "container": [Circular],
                    "instances": Map {
                      "[DEFAULT]" => Object {
                        "addAuthTokenListener": [Function bound ],
                        "getToken": [Function bound ],
                        "getUid": [Function bound ],
                        "removeAuthTokenListener": [Function bound ],
                      },
                    },
                    "instancesDeferred": Map {},
                    "name": "auth-internal",
                  },
                  "fire-auth-version" => Provider {
                    "component": Component {
                      "instanceFactory": [Function anonymous],
                      "instantiationMode": "LAZY",
                      "multipleInstances": false,
                      "name": "fire-auth-version",
                      "serviceProps": Object {},
                      "type": "VERSION",
                    },
                    "container": [Circular],
                    "instances": Map {},
                    "instancesDeferred": Map {},
                    "name": "fire-auth-version",
                  },
                  "database" => Provider {
                    "component": Component {
                      "instanceFactory": [Function anonymous],
                      "instantiationMode": "LAZY",
                      "multipleInstances": true,
                    ...(truncated to the first 10000 characters)
数据库使用公共字段uid链接到身份验证。
另外,如果你们能帮助我如何基于uid搜索集合中的文档,那么日志输出看起来好像来自其他地方,而不是
console.log(doc.data())
,因为它包含不应由
data()
返回的内部数据结构

但无论如何,要从文档中获取字段值,请使用Firebase和/或from的文档

例如,如果您在用户文档中有一个
名称
字段,则该字段应如下所示:

console.log(doc.data()['name'])

非常感谢你,我解决了这个问题。