反应-本机-火基库有一个奇怪的问题:
步骤:
尝试使用防火墙获取数据:
await firestore().collection(collectionName)
.where(ConversationModel.refs.employees, 'array-contains', '646').get();其中,646 -数组中的元素
当我使用字符串数组时,此代码按预期工作。
但是,当我设置number值(646)并尝试获取数字数组时,这段代码返回空结果。
正确示例:
等待消防局().collection(CollectionName) .where(ConversationModel.refs.employees,'array-contains','646').get();

错误示例:
等待防火墙().collection(CollectionName) .where(ConversationModel.refs.employees,'array-contains',646).get();

更新: 6.1.0 https://invertase.io/oss/react-native-firebase/releases/v6.1.0中的修复
发布于 2019-11-17 13:58:14
在这里找到的官方文档https://firebase.google.com/docs/firestore/query-data/queries说:“您可以使用新的数组-包含更多的操作符来基于数组值进行筛选”,我认为这里的关键是“值”。
在正确的字符串中,您使用的是字符串,而在错误的字符串中,您使用的是整数。然后,您可能已经将这些值存储为文本字符串,而不是整数。这里列出的受支持的数据类型https://firebase.google.com/docs/firestore/manage-data/data-types
https://stackoverflow.com/questions/58900844
复制相似问题