firebase - 在 Firestore 中的对象数组中查询子项
问题描述
我正在尝试在我的 firestore 集合中查找数组字段的元素。
这是firestore中的字段:
channels: [{name: "linkedin", date: "2020-01-02"}]
这就是我尝试查询它的方式:
firebase.firestore().collection("users")
.where("status", "==", "ACTIVE")
.where("channels", "array-contains", {
name: "linkedin"
})
解决方案
array-contains
无法对对象的特定属性值执行搜索。
如果你做类似的事情,它会起作用channels: ["Linkedin", "facebook", "twitter"]
可能您想尝试对通道使用子集合,否则,您需要将所有值提取到通道中,然后在内存中应用过滤器。
推荐阅读
- angular - 角度自定义管道返回表数据错误
- java - Java - 每次循环迭代后累加器变量不递增
- stylesheet - Drupal 8 样式表更改每次都必须重建缓存。有没有更好的办法?
- sql - 如何在 SQL Server 中创建数据集并处理每条记录?
- neo4j - 将 tsv 文件中的选定行导入 neo4j
- node.js - NodeJS - 从 Promise.all 函数返回值时获取“未定义”
- sql - 使用 SQL 从表列解析 XML
- java - 在 Oreo 及更高版本中使用 WorkManager 时是否应该显示持续通知?
- r - 如何将以下数据集合并为独立行?
- scala - Scala,使用 play 2.5 将 joda.LocalDateTime 转换为 json