-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use DataService when my entity has no 'id' property? #67
Comments
Hey @alcaidio, yes, it should be possible to implement it. If you want to contribute, PRs are always welcomed. |
PR #69 |
I would be interested in that feature, too! Unfortunately I am not sure how to contribute a solution yet but I wanted to share my current workaround, in case anybody else ends up here, too. First, I create a type to annotate the DataService with. Because it is just an extension, it should not break code already written. In my case, I just need to map an already existing attribute to type WithIdGetter<T, K extends keyof T> = T & {
get id(): T[K];
}; As my backend only returns elements of type
Again, it just adds a getter to my interface. As you can see, it works on a list of items. The principle would be very similar for just one element (you just leave out the list type and map function). Update: microsoft/TypeScript#58020 Due to this bug, I replaced the getter by a hardcoded item
This store is working fine for me (I need to use it somewhere for it to work) |
Is it possible to use an adapter to map my "id" property to "someId"?
The text was updated successfully, but these errors were encountered: