-
-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advanced populating? #42
Comments
First, I would suggest taking the pattern of storing data how it will be viewed (i.e. storing a list of actions within goals). This is actually follows Firebase's Docs on "creating structured data that scales": actions: {
actionId: {
goalId: 'goalId1',
done: false
},
actionId2: {
goalId: 'goalId1',
done: false
}
}
goals: {
goalId1: {
text: 'Goal title',
actions: {
actionId: true,
actionId2: true
}
}
} Then when calling, you can list goals with populated actions like so: const populates = [{ child: 'actions', root: 'actions' }]
@firebaseConnect(() => ([
{ path: 'goals', populates }
])) or actions with the associated goal populated like this: const populates = [{ child: 'goalId', root: 'goals' }]
@firebaseConnect(() => ([
{ path: 'actions', populates }
])) |
Thanks for the help! |
I am working on implementing the above, but it doesn't seem to work. I have created the recommended structure. My code: const populates = [{ child: 'actions', root: 'actions' }]
@firebaseConnect(() => ([ { path: 'goals', populates } ]))
@connect(({ firebase }) => ({
users: populatedDataToJS(firebase, 'goals', populates),
})) The result is an unmodified object of action ids, i.e. actions: {
actionId: true,
actionId2: true
} Any ideas? Package version: 1.2.2 |
That seems like it should be working correctly. I will attempt to replicate using the simple example and get back to you. |
Right you are! It seems that there is an issue gathering the data when populating a parameter that is a Firebase lists ( I've started a branch for |
* Population of list with items containing a child param that is Firebase list (`key: true`) using `populatedDataToJS` (#42) * `populatedDataToJS` supports childParam option (#48) * `populatedDataToJS` returns null for empty lists instead of `undefined` (#50) * Unit tests added to cover all cases within `populatedDataToJS`
|
Great news! I can confirm that this now works as expected. Thanks a lot! |
Glad to hear. There is a unit test for this pattern now too, so it shouldn't be an issue moving forward. |
A question regarding populate with the following data structure:
How would I go about populating goals with actions?
Conditions:
The text was updated successfully, but these errors were encountered: