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
Error using params options with DS.find #26
Comments
The issue appears to be related to #25. I get the following error when attempting to deserialize the account document:
|
Ok, so the issue is that I defined the users Resource as:
If I change that to hasOne it works:
I think there probably needs to be a good review of the relationships handling code. I'll look at doing that in my branch. |
Ok i think the The The reason being that a REST document should not change as a side effect of changing some other document. e.g. If we remove a user from an organisation's Users relationship there cannot be any keys, e.g. Parent keys in the child user that need to be updated as well. (This would make your user document non-cacheable) However when dealing with data on the client it is very useful to be able to access an object's parent. Business rules often require this and it is commonly implemented on server ORM's so i have implemented js-data parent relations. A |
So in you example above when the server did not include and relationships information in its response it was deserialized correctly. However when the relationships were returned in the response. We could not deserialize it correctly because we did not have the js-data definitions of the relationship. Rather than failing silently and loosing data. I chose to fail the deserialization and raise and error. |
As you pointed out the solution to your problem is to correctly define the relationship as a Child relationship!! |
After explaining this i realize that there was quite a bit of work that i did to support these parent links. I inspect the self link and extract the parent id from the link. I now realize that this is not necessary. If we only use This would require the localKey name of the child's |
I asked about belongsTo vs hasOne in the js-data Slack. This was their response:
However, I agree with you that if |
There's no problem using This is something i was thinking about, is js-data represents data in the same way as a relational database so i guess So actually if i don't change anything Just understand that a Actually can we close this one? |
I haven't really looked into this issue yet. More details to come. However if I run:
Then I see the request
/v3/users/me
and I get the model in the.then
and everything works great.However if I add a parameters option to the find it doesn't work.
I see the request
/v3/users/me?include=account
but I don't get the model in the.then
. I appears that the.then
is not called at all as I don't even get the logging message 'THERE:' in my browser's console.The text was updated successfully, but these errors were encountered: