【发布时间】:2019-12-09 08:46:13
【问题描述】:
我正在尝试创建一个查询以获取一个 Firestore 集合/文档,其中 userId 等于当前 userId 或当前 userId 等于contributorsId。
export default compose(
connect(mapStateToProps),
firestoreConnect((props) => {
if (!props.auth.uid) return []
return [
{
collection: 'canvases',
orderBy: ['createdAt', 'desc'],
where: [
['userId', '==', props.auth.uid] || ['contributors', 'array-contains', props.auth.uid]
],
}
]
})
)(CanvasSelector);
我希望它为我提供所有声明正确的文档。但它只返回第一个。如果我选择只包含其中一个查询(“where”),它们都可以工作并返回正确的文档。
【问题讨论】:
-
Firestore 不支持逻辑 OR 查询。您必须分别执行每个查询,并将它们的结果合并到客户端代码中。
标签: reactjs firebase redux react-redux google-cloud-firestore