delete method
dynamic
delete(
- dynamic field,
- dynamic value
Implementation
delete(field, value) {
if (field == null && value == null) {
throw Exception('Field $field not found');
} else if (fields.where((element) => element.field == field).isEmpty) {
throw Exception('Field $field not found');
}
database().where(field, isEqualTo: value).get().then((value) {
for (var element in value.docs) {
element.reference.delete();
}
});
firestore.collection('Xactivity').add({
'activity': 'Deleted $className',
'time': DateTime.now(),
'by' : FirebaseAuth.instance.currentUser!.email,
});
}