function addTask(e, docID) {
const obj = new ClassName(field1, field2);
var doc = db.collection(`collectionPath`).doc('doc-id');
doc.update({
tasks: firebase.firestore.FieldValue.arrayUnion(obj)
});
}
我的文档有字段 tasks = [];// an empty array initially.
上面的代码给出了错误:Uncaught FirebaseError:
<块引用>使用无效数据调用函数 FieldValue.arrayUnion()。不支持的字段值:自定义对象(在文档中找到)
我不明白它有什么问题。是不是因为 firestore 无法存储对象数组?如果是,是否有其他方法来存储对象?
我尝试使用字符串而不是对象来编写代码并且它工作正常,因此它看起来无法存储对象。