devvmh / redux-crud-store

Store of server-side models for Redux single page applications
Apache License 2.0
131 stars 23 forks source link

Configurable id field #7

Open devvmh opened 8 years ago

devvmh commented 8 years ago

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 commented 8 years ago

19, integrating normalizr, should solve this issue

chawax commented 7 years ago

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 ?

devvmh commented 7 years ago

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 commented 7 years ago

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