update_field_name_in_document function
dynamic
update_field_name_in_document({})
Implementation
update_field_name_in_document({
required String collection,
DocumentSnapshot? document,
String? document_id,
required String old_field,
required String new_field,
}) async {
if (document == null) {
document = await FirebaseFirestore.instance
.collection(collection)
.doc(document_id)
.get();
}
document.reference.update(
{old_field: FieldValue.delete(), new_field: document.get(old_field)});
}