How to delete a field in Firestore document with flutter

后端 未结 3 1393
轮回少年
轮回少年 2020-12-19 03:52

I\'m making a Flutter application.

But, I cannot delete a field in the Firestore document. In another language I know to use FieldValue.delete() to dele

相关标签:
3条回答
  • if you have nested fields then use the '.' (Dot) notation to specify the field.

    E.g if your data is nested Map then this is handy.

    Firestore.instance.collection('path').document('name').update({'address.town': FieldValue.delete()}).whenComplete((){
      print('Field Deleted');
    });
    
    0 讨论(0)
  • 2020-12-19 04:28

    I think this is currently impossible in standard, non hacky way. There is an open issue https://github.com/flutter/flutter/issues/13905 in Flutter which have to be resolved first.

    0 讨论(0)
  • 2020-12-19 04:30

    Update Oct,2018: This is Now Possible:

    In order to delete a particular field from a Cloud Firestore document - make sure you are using Plugin version 0.8.0 or Above. Now a E.g If you have a document having a field 'Desc' with contain some Text. In Order to Delete it.

    Firestore.instance.collection('path').document('name').update({'Desc': FieldValue.delete()}).whenComplete((){
      print('Field Deleted');
    });
    

    This will Delete 'Desc' Field from the Document 'name'

    0 讨论(0)
提交回复
热议问题