【发布时间】:2020-05-12 11:54:09
【问题描述】:
我在从 firebase 数据库中删除数组时遇到问题。这是我的数据库的样子
Location
0 "Maldives"
1 "Maldives"
2 "India"
有时数据库包含相同的位置。当用户尝试删除位置时,它会删除所有匹配的位置。
这是我使用的代码:
onPressed: () {
Firestore.instance
.collection('schedules')
.document(data.documentID)
.updateData({
"location":
FieldValue.arrayRemove(
["Maldives"]),
});
},
child: Text(
'Remove',
style: TextStyle(
color: Color(0xFF34495e)),
)),
如果我使用该代码,数据库的外观如下:
Location
0 "India"
我该如何解决这个问题。如果我们可以通过数组的索引删除它会容易得多。怎么删除?
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore