首页 > 解决方案 > 如何使用颤振在 FireStore Mappage 中添加元素

问题描述

在 firestore 中,我有一个包含属性映射的文档。该属性包含或可以包含很多键/值。

但是不知道怎么给这个属性加上key/values

我知道,要添加到我们可以使用的列表中FieldValue.arrayUnion([userUid])

我试过了

firestore.collection(questionCollection).document(object.id).updateData({attributeMapping: {key: FieldValue.increment(1)}});

但这会删除已插入的其他键/值。

有人可以帮助我吗?

谢谢

标签: flutterdartgoogle-cloud-firestore

解决方案


经过长时间的搜索,我最终解决了我的问题。如果对某人有帮助,我将答案放在这里

firestore.collection(questionCollection).document(object.id).setData({attributeMapping: {key: FieldValue.increment(1)}}, merge: true);

推荐阅读