我正在尝试使用merge:true
更新文档中的字段。
它不仅无法更新文档,还因为我仅使用更新的字段创建了具有相同documentID的重复文档
代码
await Firestore.instance
.collection('QuizProfile')
.document(id)
.setData({
'Score': ['asdfg'],
}, merge: true);
}
在此处添加屏幕截图
答案 0 :(得分:1)
setData
和merge:true
将更新文档中的字段或创建文档(如果不存在),而updateData
将更新字段,但如果文档不存在将失败>
如果id
等于Firestore中的原始文档ID,则可以使用updateData
:
await Firestore.instance
.collection('QuizProfile')
.document(id)
.updateData({
'Score': ['asdfg'],
});
}