firebase - 参数类型“int”不能分配给参数类型“List”'。使用 FieldValue.arrayUnion Firestore Flutter 时出错
问题描述
我正在从 RTD 切换到 Firestore,所以我对新数据库非常陌生。我正在尝试使用将值添加到文档的字段(数组)orders
,FieldValue.arrayUnion
但我得到了The argument type 'int' can't be assigned to the parameter type 'List<dynamic>'.
. 我究竟做错了什么?非常感谢。
// User collection
_firestore
.collection('Users')
.doc(_firebaseAuth.currentUser.uid)
.update({'orders': FieldValue.arrayUnion(order.orderId)});
解决方案
arrayUnion
将列表作为参数而不是 int,因此请尝试以下操作:
.update({'orders': FieldValue.arrayUnion([order.orderId])});
推荐阅读
- spring-boot - 为什么当我将 ssl 添加到我的 springboot 项目时,磁盘缓存在浏览器中不起作用?
- android - Android ViewModel 中的 Kotlin 支持属性
- javascript - Quill.js 和视频处理程序的自定义提示
- c++ - 使用字符串数组从书籍列表中查找书籍
- amazon-web-services - 是否可以在 AWSCLI 的单个脚本中创建 EC2、S3 存储桶并分配入站规则?
- java - 使用 Java Streams 获取嵌套列表的每个第 n 个元素
- telegraf - 仅按时间而不是标签聚合 Telegraf 中的数据
- firebase - 使用 Cloud Storage 上传文件执行时间过长
- java - Android Studio:需要帮助动画进度条
- javascript - 使用角度 e2e 测试时与 gojs 画布交互