Populate

Populate allows you to replace IDs within your data with other data from Firebase. This is very useful when trying to keep your data flat. Some would call it a join, but it was modeled after the mongo populate method.

Initial data from populate is placed into redux in a normalized pattern following defined redux practice of normalizing. populate helper used within the connect function then builds populated data out of normalized data within redux (NOTE: This does not apply if you are using v1.1.5 or earlier).

Some Things To Note

firebaseConnect - based on populate settings, queries are created for associated keys to be replaced. Query results are stored in redux under the value of root in the populate settings.

connect - Combine original data at path with all populate data (in redux from queries created by passing populate settings to firebaseConnect)

Populate creates a query for each key that is being "populated", but does not create multiple queries for the same key

Results of populate queries are placed under their root

Examples

List of todo items where todo item can contain an owner parameter which is a user's UID like so:

{"text":"Some Todo Item","owner":"Iq5b0qK2NtgggT6U3bU6iZRGyma2"}

Populate allows you to replace the owner parameter with another value on Firebase under that key. That value can be a string (number and boolean treated as string), or an object

Initial data from populate is placed into redux in a normalized pattern following defined redux practice of normalizing. populatedDataToJS helper used in the connect function then builds populated data out of normalized data within redux (NOTE: This does not apply if you are using v1.1.5 or earlier).

Example Result

Place Result On Another Parameter

There is also the option to place the results of a populate on another parameter instead of replacing the original child (i.e. "alias" the child result). An example of this could be populating the owner parameter onto the ownerObj parameter, which would leave the owner parameter intact (since the child from the populate was "aliased" to ownerObj).

For more details including the initial feature request, checkout issue #126.