I'm currently facing a challenge accessing specific data objects that are referenced by keys. In this particular scenario, the "applicant" data is nested within an Event object. My goal is to extract this data and create a new object from it. While I can easily access the top-level Event data and the keys for each applicant, I'm struggling to retrieve additional details such as application date, notes, and status.
My attempted approach of using something like applicationStatus = key.status has not been successful.
onCreateApplication () {
fb.eventsCollection.orderBy('startDate', 'desc').onSnapshot(querySnapshot => {
let appsArray = []
querySnapshot.forEach(doc => {
let event = doc.data()
let eventId = doc.data().id
let eventTitle = doc.data().title
let eventSlug = doc.data().slug
let applications = doc.data().applicants
// Unable to access applicant data directly
let appStatus = doc.data().applicants.status
for (var key in doc.data().applicants) {
let eventData = {
id: eventId,
title: eventTitle,
slug: eventSlug
}
let userData = {
id: key
}
// Unsure how to accurately access status and appliedDate
let application = {
event: eventData,
user: userData,
status: key.status????????,
appliedDate: key.created??????
}
fb.applicationsCollection.add(application)
}
})
})
},