如何将新数据附加到存储在 firebase 的 firestore 上的数组中?节点、Ionic3、Angular、Javascript

问题描述

需要一些帮助。我无法从 arrayUnion 访问 FieldValuefirebase.firestore。我在firestore上存储了一系列地图。即使 {merge:true} 不起作用,我也需要在同一个数组中附加数据并增加索引。我正在使用 Ionic 3。

firebase.firestore.FieldValue.arrayUnion - 在 arrayUnion 处出错。

错误是:

Property 'arrayUnion' does not exist on type 'typeof FieldValue'

解决方法

万一有人遇到同样的问题。 arrayUnion 方法在 firebase v5.3.0 及更高版本中。 它还包含了这么多的数组操作方法。只需通过 npm firebase@latest

更新 firebase