Flutter 如何使用flatter在FireStore Mappage中添加元素
在firestore中,我有一个包含属性映射的文档。 此属性包含或可以包含许多键/值 但我不知道如何添加键/值这个属性 我知道,要添加到列表中,我们可以使用FieldValue.arrayUnion[userUid] 我已经试过了Flutter 如何使用flatter在FireStore Mappage中添加元素,flutter,dart,google-cloud-firestore,Flutter,Dart,Google Cloud Firestore,在firestore中,我有一个包含属性映射的文档。 此属性包含或可以包含许多键/值 但我不知道如何添加键/值这个属性 我知道,要添加到列表中,我们可以使用FieldValue.arrayUnion[userUid] 我已经试过了 firestore.collection(questionCollection).document(object.id).updateData({attributeMapping: {key: FieldValue.increment(1)}}); 但这会删除已
firestore.collection(questionCollection).document(object.id).updateData({attributeMapping: {key: FieldValue.increment(1)}});
但这会删除已插入的其他键/值
有人能帮我吗
谢谢经过长时间的搜索,我终于解决了我的问题。 我把答案放在这里,如果它对某人有帮助的话
firestore.collection(questionCollection).document(object.id).setData({attributeMapping: {key: FieldValue.increment(1)}}, merge: true);