正如网络官方文档中所述:
要从文档中删除特定字段,请在更新文档时使用FieldValue.delete()方法:
var cityRef = db.collection('cities').doc('BJ');
// Remove the 'capital' field from the document
var removeCapital = cityRef.update({
capital: firebase.firestore.FieldValue.delete()
});
我找不到使用angularfire2(5.0.0-rc.3)实现它的方法
constructor(private firestore: AngularFirestore) {}
[...]
const cityRef = this.firestore.doc(`cities/BJ`);
cityRef.update({
capital: this.firestore.FieldValue.delete()
});
无法读取未定义
的属性'delete'
答案 0 :(得分:3)
你有可能错过进口
import * as firebase from 'firebase/app';
现在你可以尝试
capital: firebase.firestore.FieldValue.delete()