【问题标题】:Angularfire2 with firestore: delete specific fields from a document带有firestore的Angularfire2:从文档中删除特定字段
【发布时间】:2018-04-27 19:20:36
【问题描述】:

正如 web 官方文档中提到的:

要从文档中删除特定字段,请在更新文档时使用 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()
});

无法读取未定义的属性“删除”

【问题讨论】:

  • 我不确定试试capital: FieldValue.delete()

标签: angular firebase angularfire2 google-cloud-firestore


【解决方案1】:

你可能会错过导入

import * as firebase from 'firebase/app';

现在你可以试试

capital: firebase.firestore.FieldValue.delete()

【讨论】:

  • 大写:firebase.default.firestore.FieldValue.delete();
猜你喜欢
  • 2020-09-11
  • 2023-04-03
  • 2018-04-09
  • 1970-01-01
  • 2022-09-27
  • 2020-10-31
  • 2019-11-25
  • 2018-09-04
  • 2021-09-29
相关资源
最近更新 更多