2

This is my first time using StackOverflow. Hope someone can help me out!

I am trying to write React-redux application and currently trying to integrate Firebase into the application. When I console.log a collectionReference object, the object name is called n for some reason, and the keys of the object seems to be gibberish, such as Ch, Hw, etc... I am not sure what is going on. Does anyone know console.log doesn't seem to give me information on my collection object? Is it because the data is somehow encrypted for security reasons? This is the method I wrote for concole.loging a collectionReference object.

export const addCollectionAndDocuments = (collectionKeys, objectsToAdd) => {
  const collectionRef = firestore.collection(collectionKeys);
  console.log(collectionRef);
};

This is the response I get.

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
3
  • To me this does look like a Reference object; what are you expecting instead, and why? Commented Jul 14, 2020 at 0:06
  • Hi Chris! I am expecting that the console.log would print out the CollectionReference object with the associated key names. Right now, the key names are Cw, Ha, Qa ..., which I don't really know where they are coming from because I didn't set them. Commented Jul 14, 2020 at 0:14
  • 1
    I assume these are internal properties; have you tried calling .get(), .where(), etc on the reference? What I'm saying is that while I'm certainly no firestore expert, I'm not seeing anything that suggests that something went wrong. Commented Jul 14, 2020 at 0:17

2 Answers 2

1

Those Ch, hW, etc. look like minified internal properties, they're just private stuff you won't need (hence why they're not human-readable). You will not see your data enumerated on a CollectionReference, or even have access to any data directly yet, because you haven't asked for anything, only selected a collection.

Like @Chris said, use .doc() to select a document or make queries with .get(), .where and other methods to actually get data. I recommend following along the Firebase docs as you set up your app.

Sign up to request clarification or add additional context in comments.

Comments

1

I'm not sure what you're expecting the console log to print out, but Christian is right, you're looking at a mangled internal representation of a CollectionReference object. It doesn't have a meaningful string format.

If you want to log something meaningful, perhaps you could use path or one of its other documented properties. If you need document data from that collection, you'll have to make a query with it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.