【发布时间】:2019-05-26 20:39:01
【问题描述】:
下面的行将firestoreConnect 指向我标记为projects 的集合。
{ collection: 'projects' }
当项目集合像这样直接位于根目录下时,它可以工作:
root/
projects/
但是如果项目集合被一个本身在另一个集合中的文档引用怎么办,比如说,像这样:
root/
users/
alice/
projects/
如何将firestoreConnect 指向projects 集合?
The documentation is silent on the matter.
Link to videoimport React, { Component } from 'react'
import ProjectList from '../projects/ProjectList'
import Notifications from './Notifications'
import { connect } from 'react-redux'
import { firestoreConnect } from 'react-redux-firebase'
import { compose } from 'redux'
import { Redirect } from 'react-router-dom'
class Dashboard extends Component {...}
const mapStateToProps = (state) => {
// console.log(state);
return {
projects: state.firestore.ordered.projects,
auth: state.firebase.auth,
}
}
export default compose(
connect(mapStateToProps),
firestoreConnect([
{ collection: 'projects' }, // <-- Question is about this line
])
)(Dashboard)
编辑:不成功的尝试
From what I can piece together from the comments here 答案似乎是:
firestoreConnect([
{
collection : 'users',
doc : 'alice',
collection : 'projects',
}
])
但那次尝试失败了。
【问题讨论】:
-
对于任何错误的沟通,我深表歉意,但您能找到解决此问题的方法吗?在遵循完全相同的教程时,我遇到了类似的问题。我的预期结构看起来像“集合:课程,文档:state.auth.uid,集合:讲座”,但没有成功。
标签: reactjs firebase react-redux google-cloud-firestore react-redux-firebase