i'm using redux rest api uses uuid's. usual pattern storing state using id's key objects:
entities: { articles: { 1: { id: 1, title: 'some article', author: 1 }, 2: { id: 2, title: 'other article', author: 1 } }, users: { 1: { id: 1, name: 'dan' } } }
how use uuid's api in this? i'd able create new entity without having request uuid server first (for offline capabilities).
should i:
- use local id's, keep uuid in
_id
property of entity, , use when making api request? seems easiest way, although feels redundant , have search through entities_id
in cases.
entities: { articles: { 1: { _id: 'uuid', title: 'some article', author: 1 }, 2: { id: 'uuid', title: 'other article', author: 1 } }, users: { 1: { _id: 'uuid', name: 'dan' } } }
- use uuid's api, , when creating new item use sort if temporary id until api call resolved? seems best way, although i'm not sure how go changing id's, feels wrong (as they're id's).
entities: { articles: { 'uuid': { _id: 'uuid', title: 'some article', author: 'uuid' }, 'uuid': { _id: 'uuid', title: 'other article', author: 'creating' } }, users: { 'uuid': { _id: 'uuid', name: 'dan' }, 'creating': { name: 'stan' } } }
- do other way?
i wouldn't add redux store until api returns response.
in vue, in data given component have 2 (sometimes more) root keys, 1 of points part of redux store handles data, , other form
or of sort, , vue data changes due binding.
after user initiates action add resource (post /resources
), , server returns successful response, dispatch action addedresource
. , prior i'd dispatch addingresource
, etc.
is there reason wouldn't work? there shouldn't difference using auto incremented, integer id field vs. uuid. data normalization should still work same way.
Comments
Post a Comment