0

I was using Realtime Database and am now migrating to use Firestore. Previously, I was storing my providerData as an array, since one account can have multiple providers assigned. Right now, I'm trying to keep the same structure for Firestore, but it doesn't store the providerData object inside the array.

I saw some comments on how Firestore doesn't allow custom objects and already transformed the Firebase object into Javascript pure object.

My profileFactory is currently like this:

profileFactory: (data, profile) => {
  const helperProviderData = (profile.providerData || data.providerData || data.user.providerData);
  const providerData = JSON.parse(JSON.stringify(helperProviderData));
  return ({
    ...profile,
    role: 'user',
    providerData,
    test: providerData[0],
  });
}

On Firestore, I have the test field correctly populated, but the providerData field is set as an Array with one empty Object.

These are the versions:

"@firebase/app": "0.4.19",
"@firebase/auth": "0.12.1",
"@firebase/database": "0.5.7",
"@firebase/firestore": "1.6.1",
"react-redux-firebase": "^3.0.2",
"redux-firestore": "^0.11.0",

Is it possible to set as an Array of providers or I'll need to create a provider field for each provider accepted by my app?

Minoru
  • 1,680
  • 3
  • 20
  • 44
  • In my opinion it should work properly. Can you provide example of `helperProviderData`? – vitooh Dec 11 '19 at 08:01
  • Found out that the issue is not with the Firestore connection. For some reason which I'm not sure yet, when creating an object with `providerData`, the Objects inside the Array are empty, while if I pick the first position of the Array, I get the object properly. I'll still dig a bit more when I have more time. – Minoru Dec 12 '19 at 13:38
  • That's why I am asking about it. I have tested all possible structures of data available in Firestore and didn't' found such behavior. Maybe the problem is with obtaining data from Firestore to `profile` argument – vitooh Dec 13 '19 at 10:29

0 Answers0