Flutter:如何在firebase中删除特定的数组数据 [英] Flutter: How to remove a specific array data in firebase
本文介绍了Flutter:如何在firebase中删除特定的数组数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在在Firebase中遇到问题.我尝试删除/删除特定数组数据的地方.最好的方法是什么?附言我只是Firebase/flutter的新手.
I'm having a problem right now in firebase. Where I try to delete/remove a specific array data. What is the best way to do it? Ps. I'm just new in firebase/flutter.
我的数据库结构:
我要在我的数据库结构中删除的数据(突出显示的一个):
Data that i'm trying to remove in my database structure(Highlighted one):
推荐答案
首先创建一个空白列表,然后在列表中添加要删除的元素,然后使用以下方法更新
注意:对于这种方法,您需要要删除的元素的文档ID
Note : For this method you need the documennt id of element you want to delete
var val=[]; //blank list for add elements which you want to delete
val.add('$addDeletedElements');
Firestore.instance.collection("INTERESTED").document('documentID').updateData({
"Interested Request":FieldValue.arrayRemove(val) })
这篇关于Flutter:如何在firebase中删除特定的数组数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文