r-park / todo-redux-saga

Todo app with Create-React-App • React-Redux • Redux-Saga • Firebase • OAuth
https://todo-redux-saga.firebaseapp.com
MIT License
191 stars 49 forks source link

firebase classes for more complex data structures #6

Open mvanlonden opened 7 years ago

mvanlonden commented 7 years ago

Hey @r-park love this example. I've applied this example's logic to a more complex firebase structure with denormalized entries.

How would you recommend building a firebase model that can support lists of objects like this?

{
  "some-list" : {
    "-KbgyM0uO2l9oHCDwzAq" : {
      "prop" : "great",
      "some-ids" : {
        "-KbgyM-bzdBprmzIePhp" : true,
        "-KbwQ_AiyQcagPHnoEeI" : true
      },
      "other-ids" : {
        "again" : true,
        "nice" : true,
        "try" : true,
        "word" : true
      }
    },
    "-KbhA_tJ9ZyqQVzwHwWT" : {
      "item" : "fun",
      "some-ids" : {
        "-KbhA_sCvTVPBaFBRYcL" : true,
        "-KbwIevJI96eLSBP9h3b" : true
      },
      "other-ids" : {
        "again" : true,
        "new" : true,
        "nice" : true,
        "try" : true
      }
    }
  }
}

The existing firebase-list works really well for a list of simple objects, but is a little clunky for lists with other simple lists nested inside. Maybe some sort of composable model structure? I've also looked at firebase-saga which takes a more functional approach, although, I like being able to set the class properties in the watchers.

I'm a little torn on how to proceed. What do you recommend for more complex, denormalized structures?