Incorrect store update after entity update
See original GitHub issueType Bug
Description I was playing around with your library and noticed that an after updating an entity, the new entity data appeared at the root level of my store instead of within the entity.
Steps to reproduce
- Subscribe to a (sub)collection
- Update an entity in the Firestore manually by for example adding a field
foo: "bar"
or by programmatically bythis.movieService.update({ id: 1, foo: "bar" })
- The movie store will update incorrectly:
Actual store update (diff)
movies --> { id: 1, foo: "bar" }
Desired store update (diff)movies --> entities --> 1 --> { id: 1, foo: "bar" }
Reason The store is updated with an incorrect update function (missing id) in line 44: https://github.com/dappsnation/akita-ng-fire/blob/b9062a8c9a4b62e8d6d1ae6355255164177cea17/projects/akita-ng-fire/src/lib/utils/sync-from-action.ts#L36-L46 The update function is missing the entity id.
Solution
Per the Akita documentation:
runEntityStoreAction(BooksStore, EntityStoreAction.UpdateEntities, update => update(2, { title: 'New title' }));
So this should do the trick:
update => update(data)
should become update => update(entityIds, data)
Fix Pass on entity id to update function, see PR #134
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Tested and working 🥇
Thanks! I’ll test ASAP 🎉