这是我第一次使用 StackOverflow。希望有人能帮助我!
我正在尝试编写 React-redux 应用程序,目前正在尝试将 Firebase 集成到该应用程序中。当我console.log一个collectionReference
对象时,由于某种原因,该对象名称被称为n
,并且该对象的键似乎是乱码,例如Ch ,Hw,
等等...我不知道发生了什么。有谁知道 console.log 似乎没有给我有关我的集合对象的信息?是因为出于安全原因数据以某种方式加密了吗?这是我为 concole.logging collectionReference
对象编写的方法。
export const addCollectionAndDocuments = (collectionKeys, objectsToAdd) => {
const collectionRef = firestore.collection(collectionKeys);
console.log(collectionRef);
};
这是我得到的回复。
n {qa: t, Hd: t, dw: t, firestore: t, Qa: null, …}
Cw: n {segments: Array(1), offset: 0, m: 1}
Hd: t {s: t, ignoreUndefinedProperties: false, serializer: Ft}
Qa: null
dw: t {path: n, collectionGroup: null, ds: Array(0), filters: Array(0), limit: null, …}
firestore: t {Bd: FirebaseAppImpl, qd: t, INTERNAL: {…}, qa: t, jd: "[DEFAULT]", …}
id: (...)
parent: (...)
path: (...)
qa: t {projectId: "shop-2b337", database: "(default)"}
__proto__: n
最佳答案
那些 Ch
、hW
等看起来像是缩小的内部属性,它们只是您不需要的私有(private)内容(因此它们不是人类的原因-可读)。您将看不到在 CollectionReference
上枚举的数据,甚至还无法直接访问任何数据,因为您没有请求任何内容,只是选择了一个集合。
就像@Chris所说,使用.doc()
来选择文档或使用.get()
、.where
和进行查询其他实际获取数据的方法。我建议遵循 Firebase docs 当您设置应用程序时。
关于javascript - Firebase 集合方法不返回 CollectionReference 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62885723/