我正在尝试删除带有多路径位置的字段文档 Firestore批处理方法。我曾经使用实时数据库上的更新方法来做到这一点。现在我真的不知道如何在Firestore上做到这一点。
deleteVenueFromEvent(event)
{
var eventkey = event.$key;
var venuekey = event.venue.venuekey;
var batch = this.afs.firestore.batch();
var eventRef = this.eventCollection.doc(eventkey).ref;
batch.update(eventRef, { venue: null });
var deleteVenueRef = this.venueCollection.doc(venuekey).collection('events').doc(eventkey).ref;
batch.delete(deleteVenueRef);
batch.commit().then(function() {console.log('Batch Delete')});
}
答案 0 :(得分:1)
我找到了使用以下代码的方法:
var deleteVenueRef = this.venueCollection.doc(venuekey).ref;
batch.update(deleteVenueRef, {['events.' + eventkey] :firebase.firestore.FieldValue.delete()});