2

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
    })
  )
)

Here is a screenshots of my data in firestoreenter image description here enter image description here enter image description here

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
WhoIsDT
  • 695
  • 2
  • 9
  • 27

2 Answers2

0

Try changing the type of the profile field from string to reference. When making the profile field a reference then your data will be populated. When storing to a reference field you also need to include the collection in which the reference is. This means that the data in the profile field should look something like this "roles/{roleId}", of course you should replace {roleId} with the id of the role you are trying to save in the profile field. In the first picture that you displayed the data in the profile field should look something like this: 'roles/q3Kb0dM2XBRzS4IIrDm'

P.S. If you add the reference field from code, use this line

db.doc(roles/${roleId})

db being your firestore object that you get by using getFirestore() in the action.

Mircea Matei
  • 275
  • 2
  • 5
0

If you configure your code as per the rrf docs's populate section with useFirestoreForProfile set to true, you'll see the following console.warning:

Profile population is not yet supported for Firestore

It seems like it's not supported right now

See this issue for more details

pureth
  • 680
  • 6
  • 9