【问题标题】:Firebase Delete Function not working correctlyFirebase 删除功能无法正常工作
【发布时间】:2018-07-06 07:00:31
【问题描述】:

一些奇怪的事情正在发生..

我正在尝试从 firebase 中删除文档,问题是 即使在集合中找不到 ID 它给了我一个成功的消息。

这是 firebase 上的错误吗???

DeleteOrganization(id) {
    return this.afs.collection('organizations').doc(id).delete()
      .then( () => {
        console.log('Document successfully deleted!');
      }).catch( (error) => {
        console.error('Error removing document: ', error);
      });
  }

【问题讨论】:

  • 1.谢谢你的回答。我认为你说的是​​真的,他们只是简单地返回 true ,如果他们可以删除,或者文档不在集合中。但你知道,有时,我们需要那个 :) 感谢兄弟的回答

标签: angular firebase google-cloud-firestore document


【解决方案1】:

delete 方法让您确认文档不存在。该文档不必提前存在。

如果您需要在删除之前确保文档存在,您应该自己检查一下,尽管我认为您不会从中获得任何好处(对于相同的最终结果,这只是额外的工作)。

【讨论】:

  • 所以,你说这不是错误?
  • @RonRoyston 实时数据库的工作方式相同,所以我要说这不是错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-18
  • 2020-02-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-13
相关资源
最近更新 更多