In Firestore, I am trying to update documents in a loop with the batch method.
How come this code works :
var batch = this.afs.firestore.batch();
var eventRef = this.eventCollection.doc(eventkey).ref;
batch.update(eventRef, updateField );
var artistRef = this.memberCollection.doc('7yLf6RgLIIEUkAJ3jbXy').collection('events').doc(eventkey).ref; 
batch.update(artistRef, updateField); 
var artistRef = this.memberCollection.doc('eJtcLZrUZhhObWcmptQs').collection('events').doc(eventkey).ref; 
batch.update(artistRef, updateField); 
batch.commit().then(function() {console.log('success')};
But this one doesn't work :
var batch = this.afs.firestore.batch();
var eventRef = this.eventCollection.doc(eventkey).ref;
batch.update(eventRef, updateField );
if(artists) {
  Object.values(artists).forEach(function(artist) {
    var artistkey = artist.$key;
    var artistRef = this.memberCollection.doc(artistkey).collection('events').doc(eventkey).ref;
    batch.update(artistRef, updateField); 
  });
}
batch.commit().then(function() {console.log('success')};
It tells me "ERROR TypeError: Cannot read property 'memberCollection' of undefined"
 
    