React-admin: [question] Custom id/primary key

Created on 13 May 2017  Â·  4Comments  Â·  Source: marmelab/react-admin

Hello! I've been looking through the docs and I couldn't find how to define a model and datagrid that can use a primary key which is not named "id". For example, we have a Location resource with

code: zipcode, primary key
name: some string

The REST endpoint is still /locations/:code/ and works ok, acting on the code attribute.

Is this possible? Thanks!

Most helpful comment

All 4 comments

From what I know, admin-on-rest requires an id field for each item. It can be integer or string, but it is definitely required. It may be much easier to change backend or your restClient to rename code field into id.

And the tutorial for doing this is online: https://marmelab.com/admin-on-rest/FAQ.html#can-i-have-custom-identifiers-primary-keys-for-my-resources

Thank you!

On 16 May 2017 at 08:56, Francois Zaninotto notifications@github.com
wrote:

And the tutorial for doing this is online: https://marmelab.com/admin-on-
rest/FAQ.html#can-i-have-custom-identifiers-primary-keys-for-my-resources

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/marmelab/admin-on-rest/issues/670#issuecomment-301705193,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAeeLfOiFYOrtpXa7kxvu0qrVW39Ac1Uks5r6VbKgaJpZM4NaLXA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fzaninotto picture fzaninotto  Â·  3Comments

waynebloss picture waynebloss  Â·  3Comments

phacks picture phacks  Â·  3Comments

nicgirault picture nicgirault  Â·  3Comments

mbj36 picture mbj36  Â·  3Comments