I'm currently manually itearting over document fields in firestore and putting them into an object which I stringify to JSON.
Is there a way to automate the process? Something like:
var userEnrollments = ToJson(await admin.firestore().collection(USERS + "/" + x.uid + "/" + ENROLMENT));
DocumentSnapshot has a method data() that returns the entire contents (without subcollections) of the document as a plain JavaScript object.
admin.firestore().doc('path/to/doc').get().then(snapshot => {
const data = snapshot.data() // a plain JS object
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With