-1

I found an answer that helps me, but it is for a previous version of Angular. I'm working with Angular 6 and the code below is very helpful, but it's not compatible with the version I'm using.

Can you rewrite this code for Angular 6?

this.feedCollection = this.afs.collection('col-challange');
this.feedItem = this.feedCollection.snapshotChanges().map(changes => {
      return changes.map(a => {
        //here you get the data without first name
        const data = a.payload.doc.data() as Feed;
        //get the signup_id for getting doc from coll-signup
        const signupId = data.signup_id;
        //get the related document
        return afs.collection('coll-signup').doc(signupId).snapshotChanges().take(1).map(actions => {
          return actions.payload.data();
        }).map(signup => {
          //export the data in feeds interface format
          return { firstName: signup.firstName, ...data };
        });
      })
    }).flatMap(feeds => Observable.combineLatest(feeds));

Attempt to combine two collections Firebase Firestore, as shown in the example.

Roxgüel
  • 101
  • 1
  • 3
  • Not compatible, as evidenced by what kind of error message, or incorrect behavior? –  Jul 16 '18 at 04:13

1 Answers1

0

All you have to do is import RxJS operators like flatMap and map from 'rxjs/operators' the other stuff comes from 'rxjs' (combineLatest). Then

...snapshotChanges().pipe(
    // comma separated list of operators used in your code
      map(/*the thing you do in map*/),
      flatMap(/* the things in flatMap)
      }
SirDieter
  • 309
  • 2
  • 9
  • Please, can you do the correct transcription of the code? Because when I do it in my code editor, it throws a lot of errors, and I really do not know how to fix them. – Roxgüel Jul 15 '18 at 21:57
  • No one here provides free fix-your-code consulting services. You need to report what the error messages are, and then maybe someone would help you. –  Jul 16 '18 at 04:15
  • @Roxgüel use this code, I've implemented it in Angular6, RxJx 6 and AngularFire v5.0 [link](https://stackoverflow.com/a/52490962/5410830) – skaveesh Sep 25 '18 at 09:31