Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getCourses() {
- return this.afs.collection<Course>('courses').snapshotChanges()
- .map(course => {
- return course.map(a => {
- const courseData = a.payload.doc.data()
- const courseId = a.payload.doc.id;
- // get sections
- const sectionsRef = this.afs.collection(`courses/${courseId}/sections`)
- sectionsRef.snapshotChanges()
- .subscribe(section => {
- return section.map(se => {
- const sectionData = se.payload.doc.data()
- const sectionId = se.payload.doc.id;
- const theSection = { sectionId, sectionData };
- console.log('theSection', theSection)
- // get _items
- const itemsRef = this.afs.collection(`courses/${courseId}/sections/${sectionId}/items`)
- itemsRef.snapshotChanges()
- .subscribe(item => {
- return item.map(i => {
- const itemData = i.payload.doc.data()
- const itemId = i.payload.doc.id;
- const theItem = { itemId, itemData };
- console.log('theItem', theItem)
- return theItem
- });
- })
- })
- })
- });
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement