redux-crud-store icon indicating copy to clipboard operation
redux-crud-store copied to clipboard

Configurable id field

Open devvmh opened this issue 8 years ago • 4 comments

Currently this library assumes all records have a unique id attribute. This should be configurable instead, and shouldn't be assumed to be a number.

devvmh avatar May 23 '16 02:05 devvmh

#19, integrating normalizr, should solve this issue

devvmh avatar Jul 25 '16 03:07 devvmh

Hi, I had a problem retrieving records and I found it is because my records have a unique id but it has not the "id" name. It looks like redux-crud-store needs this to fill the ids attribute and others in state. Is this what you mean with "configurable id field" ? Do you talk about the possibility to set another name for this id attribute ?

chawax avatar May 23 '17 15:05 chawax

Hi, you're exactly right. I was anticipating this day haha.

I'm slowly working through removing immutable js from the lib so i dont have a lot of capacity to fix this issue. I would certainly welcome and collaborate on a pull request to implement this issue though!

devvmh avatar May 23 '17 16:05 devvmh

If course if you own the backend server it wpukf be mich simpler to replicate the contents of your existing id field and have the unique identifier available under both keys. You could even hide this behaviour under a parameter (e.g. /api/v1/posts returns a regular response, but /api/v1/posts?include_id=true returns the same response with the id key added), and then pass that parameter to the ApiClient configuration so it's included in all requests from redux crud store to your server

devvmh avatar May 23 '17 16:05 devvmh