所以我正在使用这个包,并且想要应用this reciept来填充来自我的firestore中名为'roles‘的集合的数据到我的处于redux状态的firebase/profile数据。
在这篇文档中,我的roles集合必须是firestore中的users集合的同级集合,但在我的例子中这是不可能的。我有不同的集合: Users和Roles,前者存储有关用户的数据,后者存储应用程序树和按角色访问。
如何使用这个包在不同的集合之间填充数据?请帮帮我..
我使用下面的代码进行设置:
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
})
)
)这是我在firestore中的数据截图



发布于 2019-09-30 03:45:56
尝试将profile字段的类型从string更改为reference。当将配置文件字段设置为引用时,您的数据将被填充。当存储到引用字段时,您还需要包括引用所在的集合。这意味着profile字段中的数据应该类似于此"roles/{roleId}",,当然,您应该将{roleId}替换为您试图在profile字段中保存的角色的id。在您显示的第一张图片中,profile字段中的数据应如下所示:'roles/q3Kb0dM2XBRzS4IIrDm‘
附注:如果从代码中添加引用字段,请使用下面这一行
db.doc(
roles/${roleId})
db是您通过在操作中使用getFirestore()获得的firestore对象。
发布于 2021-04-24 18:17:17
如果在useFirestoreForProfile设置为true的情况下按照rrf docs's populate部分配置代码,您将看到以下console.warning
Profile population is not yet supported for Firestore现在似乎还不支持它
有关更多详细信息,请参阅this问题
https://stackoverflow.com/questions/56394558
复制相似问题