0
votes

I'm new to firebase, and when i perform a get command for a firestore document it returns a ton of data that are not fields i set myself. Is there anyway to get only the user defined data? Example below, only 6 of these were user defined fields. None of the others are even visible in the web console.

code...

db.collection("profiles").doc("a").get();

response

I: [] ​​ length: 0 ​​ : Array [] ​ J: true ​ O: Array [ () ] ​ P: Array [] ​ Sb: Object { l: "[redacted]", … } ​ W: function () ​ Xa: null ​ Y: Object { l: false, settings: {…}, W: "[redacted]", … } ​ Z: Object { l: false, settings: {…}, W: "[redacted]", … } ​ _lat: "[redacted]" ​ a: Object { c: "[redacted]", … } ​ b: Object { a: "[redacted]", c: 1611707738951, … } ​ da: Object { a: "[redacted]", b: {…} } ​ displayName: "[redacted]" ​ email: "[redacted]" ​ emailVerified: false ​ ga: null ​ h: null ​ i: Object { v: 0, B: "[redacted]", … } ​ isAnonymous: false ​ l: "[redacted]" ​ la: undefined ​ m: "[redacted]" ​ ma: "[redacted]" ​ metadata: Object { a: "[redacted]", … } ​ o: "[redacted]" ​ phoneNumber: null ​ photoURL: null ​ providerData: Array [ {…} ] ​ refreshToken: "[redacted]" ​ tenantId: null ​ u: Object { src: {…}, a: {…}, b: 3 } ​ uid: "[redacted]" ​ va: false ​ w: Object { c: 30000, f: 960000, a: 30000, … } ​ wa: function wa(e)​ xa: function xa(e)​ : {…

1
"Questions seeking debugging help ('why isn't this code working?') must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." - Frank van Puffelen

1 Answers

1
votes

What you're printing is the entire DocumentSnapshot, which contains a lot more metadata in addition to the actual data of the document.

To see only the data:

let documentSnapshot = await db.collection("profiles").doc("a").get();
console.log(documentSnapshot.data());