So i'm using this package, and want to apply this reciept to populate data from collection called 'roles' in my firestore to my firebase/profile data in redux state.
In this docs says, that my roles collection must be a sibling of users collection in firestore, but in my case it's not possible. I have different collections: Users, which stores data about users, and Roles, which stores app tree and access by roles.
How to populate data between different collections using this package? Please help me..
i'm using this code for setup:
const store = createStore(
rootReducer,
composeEnhancers(
applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
reduxFirestore(fbConfig),
reactReduxFirebase(fbConfig, {
useFirestoreForProfile: true,
userProfile: 'users',
profileParamsToPopulate: [
{ child: 'profile', root: 'roles' }, //But that's not working because roles is not sibling of users
],
attachAuthIsReady: true
})
)
)
答案 0 :(得分:0)
尝试将配置文件字段的类型从字符串更改为引用。当将配置文件字段作为参考时,将填充您的数据。当存储到参考字段时,您还需要包括参考所在的集合。这意味着配置文件字段中的数据应类似于此“角色/ {roleId}” ,当然,您应该用角色ID替换{roleId} 您正在尝试保存在配置文件字段中。在显示的第一张图片中,配置文件字段中的数据应如下所示:“ roles / q3Kb0dM2XBRzS4IIrDm”
P.S。如果您从代码中添加引用字段,请使用此行
db.doc(
roles/${roleId}
)
db是您通过在操作中使用 getFirestore()获得的Firestore对象。
答案 1 :(得分:0)
如果您按照 rrf docs's populate 部分配置代码并将 useFirestoreForProfile
设置为 true,您将看到以下 console.warning
:
Profile population is not yet supported for Firestore
现在好像不支持?
请参阅 this 问题了解更多详情