无法使用映射更新 Firestore 数据库 -"参数无效:'约会槽'的实例"



当我试图用我的电子邮件字段的新更新值更新我的Firestore数据库时,我遇到了一个问题,该字段是我的Firestore数据库中地图列表的一部分。

我正在尝试用特定的电子邮件id更新电子邮件字段。

我已经包含了我的Firestore集合和用于更新Firestore文档的代码,还包含了对象具有的值和更新的信息。

当它试图运行以下代码片段时,它会给我错误"无效参数:'AppointmentSlot'的实例">

有人能帮我解释为什么会出现这个错误以及解决它的方法吗?如有任何帮助,我们将不胜感激。

我的Firestore收藏

代码片段,其中我为日期"更新文档;3-17-2022";

调试器显示更改的图片我正在尝试更新

预约模型信息

我想知道Firestore是否在更新数据时遇到问题,因为它对我的自定义对象预约批次一无所知。

关于如何解决这个问题有什么建议吗?下面是我如何称之为的代码片段

Future updateAppointment(AppointmentsInfo appointmentsInfo) async {
try{
return await appointments.doc(appointmentsInfo.selectedDate).set({
'appointmentslots' : **appointmentsInfo.appointmentslots**,
'day' : appointmentsInfo.day,
'selecteddate' : appointmentsInfo.selectedDate,
}, SetOptions(merge: true));
} catch(e){
print(e.toString());
}

}

这是我为约会信息定义的类。

class AppointmentSlot {
final String email;
final String slot;
AppointmentSlot({ required this.email, required this.slot });
}
class AppointmentsInfo {
final List<**AppointmentSlot**> appointmentslots;
final String day;
final String selectedDate;
AppointmentsInfo({ required this.appointmentslots, required this.day, required this.selectedDate });
// AppointmentsInfo({ required this.day });
}

最新更新