Query data across different collections in Firestore


#1

I have 2 collections: one for newspapers and another one for user registered:
enter image description here

enter image description here

At moment I’m displaying my newspapers:
enter image description here

The bookmark button (the one on the left) adds the newspaper to the user collection (as we can see on second image) but I’m not checking this when I’m getting the newspapers. How could I do this to change the button color?

This is how I get newspapers and how I save them into users collection:

getDefaultNewspapers() {
    this.newspapers$ = this.likes$.pipe(
      switchMap(likes =>
        this.angularFirestore
          .collection<NewspaperModel>("newspapers", ref =>
            ref.where("likes", ">=", likes).orderBy("likes", "desc") // forget about this filter
          )
          // .valueChanges()
          .snapshotChanges() // necessary for metadata like IDs
          .map(newspapers => {
            return newspapers.map(newspaper => {
              const $id = newspaper.payload.doc.id;
              const data = newspaper.payload.doc.data() as NewspaperModel;
              return { $id, ...data };
            });
          })
      )
    );
  }

  addRemoveFavourite(newspaperId: string) {
    this.angularFirestore
      .collection("users")
      .doc(this.afAuth.auth.currentUser.uid)
      .update({
        ["myNews." + newspaperId]: {
          favourite: false,
          visits: 0
        }
      });
  }