Firebase:arrayUnion导致DocumentReference.update失败

时间:2020-05-12 20:31:25

标签: firebase google-cloud-firestore

我正在为Firebase中的文档建立工厂,以后必须由另一个文档引用。列表将这些条目存储在引用数组中。

import firebase from 'firebase/firebase';

//...

let listDoc = db.collection('lists').doc(listId)
db.collection('entries').add({ ... })
  .then(entry => {
    listDoc.update({
      entries: firebase.firestore.FieldValue.arrayUnion(entry)
    })
  });

由于以下原因,此操作失败:FirebaseError: Function DocumentReference.update() called with invalid data. Unsupported field value: a custom bI object (found in field entries)

我认为也许是出于某种原因而被参考引用所吸引,但是即使我将entry.id传递给arrayUnion方法,它也会产生相同的错误。我检查了arrayUnion的文档,这似乎与预期的一样-我在这里错过了什么?

Firebase JS SDK版本7.14.2

1 个答案:

答案 0 :(得分:0)

这似乎可以通过将导入从firebase/firebase更改为firebase/app来解决-该类型在两者中均有效,但是只有firebase/app返回正确的数据结构。

相关问题