Error in deleting specific field in a cloud firestore document

对着背影说爱祢 提交于 2020-04-17 22:52:03

问题


I'm using this code from here

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

I'm using

 cloud_firestore: 0.13.2+1

However, this throws an error

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'MethodChannelFieldValue' is not a subtype of type 'FieldValuePlatform'

Can anyone tell me how to delete a field right way


回答1:


You may refer to the official Firestore documentation for guidance on how to delete fields.

var cityRef = db.collection('cities').doc('BJ');

// Remove the 'capital' field from the document
var removeCapital = cityRef.update({
    capital: firebase.firestore.FieldValue.delete()
});



来源:https://stackoverflow.com/questions/60759410/error-in-deleting-specific-field-in-a-cloud-firestore-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!