Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: How to remove a specific array data in firebase

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.

My database structure:

enter image description here

Data that i'm trying to remove in my database structure(Highlighted one):

enter image description here

like image 569
Lix Avatar asked Dec 10 '19 13:12

Lix


1 Answers

First create a blank list and add element in the list which you want to remove then Update using below method

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) })
like image 136
Shailendra mewada Avatar answered Nov 15 '22 09:11

Shailendra mewada