I am attempting to retrieve all fieldnames within the payload > (random doc id) objects.
https://i.sstatic.net/y9703.png
At this moment, my approach involves fetching other collections using the following code:
async fetchPage() {
const query = firebase
.firestore()
.collection('PAGES')
.where('type', '==', 'page')
try {
const { docs } = await query.get()
this.pageIndex = docs.map((doc) => {
if (doc && doc.exists) {
this.items = doc.data()
}
let { id } = doc
const data = doc.data()
return { id, ...data }
})
console.log('Loaded items', this.items)
} catch (error) {
throw new Error('Something went wrong!')
}
},
Firstly, I would like to know the best practice for querying objects. I have referenced this documentation from Firebase but did not find it helpful when implementing the query.
Secondly, given that the child object of the payload represents the actual id of its document, what procedure should I follow to specify that I'm searching for something like payload > doc id > content: "This is some content"?.