- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想返回documentID,以便我可以存储它并在以后使用。我试图将createPrescription的返回值存储为动态类型,但是我也遇到了错误。
await DatabaseService().createPrescription(date, ic, illness, medication, important);
Future createPrescription(String newdate, String patientid, String sickness, String meds, String notes) async {
return await prescriptionCollection.document().setData({
'date' : newdate,
'patientID' : patientid,
'illness' : sickness,
'medication' : meds,
'important' : notes
});
最佳答案
您不应该使用await prescriptionCollection.document().setData()
,因为您没有为document()提供任何ID。
如果您希望Firestore为您生成一个ID,则应改为await prescriptionCollection.add()
,它返回对具有已生成ID的已创建文档的引用
您可以执行以下操作:
Future createPrescription(String newdate, String patientid, String sickness,
String meds, String notes) async {
var _ref = await prescriptionCollection.add({
'date': newdate,
'patientID': patientid,
'illness': sickness,
'medication': meds,
'important': notes
});
print(_ref.documentId);
}
关于firebase - 您可以返回刚刚添加到集合中的文档的文档ID吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59981611/
实现信息技术的自主可控,可以说是金融行业最紧迫、最重要的推进战略了。 人民银行、银保监会等主管部门密集出台文件,指导金融行业核心领域自主可控技术应用。 拿数据库来说,自主可控这事儿业内也
在methods中创建方法showtime,传入要跟当前时间要对比的时间 ?
其实这个没什么技术含量,当然就直接贴代码,不废话了, 但是在其实开发中还是蛮有用的,譬如论坛帖子,围脖等都有相关应用 复制代码代码如下: function tranTim
今天,杭州人的朋友圈都被这场晚会刷屏了 分散在全球的阿里人都回到杭州,为阿里巴巴送上20周岁的生日祝福。 阿里巴巴20周年年会,被称作“有史以来杭州规模最大的年会”,没有
在很多场合为了显示出信息的及时性,一般会将时间显示成“刚刚”,“5分钟前”,“3小时前”等,而不是直接将时间打印出来。比如微博,SNS类应用就最长用到这个功能。而一般存储在数据库中的时间格式为 Un
我是一名优秀的程序员,十分优秀!