Closed rgant closed 8 years ago
Here are the variable passed to update
:
config = Defaults {defaultValues: Object, methods: Object, computed: Object, scopes: Object, actions: Object…},
id = "659",
attrs = undefined,
options = Options {}
Stepping through code I noticed that the attr became undefined at this last step:
Could this be the missing callback from #11?
Yes i think it may be related to #11. I was not able to reproduce this behaviour and always had cb set whenever the lifecycle event was triggered.
I tried to reproduce this:
see: describe('DS#Save', function () { ..});
here
Though the documentation says cb is not passed for synchronous actions.
And beforeUpdate
is called on:
save
update
updateAll
Maybe this had to do with my using js-data-angular plugin? I also didn't have issues until I tried to use both AngularJS and js-data-jsonapi.
On Tue, Jun 28, 2016, 19:26 Blair notifications@github.com wrote:
Yes i think it may be related to #11 https://github.com/BlairAllegroTech/js-data-jsonapi/issues/11. I was not able to reproduce this behaviour and always had cb set whenever the lifecycle event was triggered.
I tried to reproduce this:
- Loading data from the server.
- Updating
- Calling save on the resource
see: describe('DS#Save', function () { ..}); here https://github.com/BlairAllegroTech/js-data-jsonapi/blob/js-data-jsonapi/test/update.spec.js#L80
Though the documentation says cb is not passed for synchronous actions. And beforeUpdate is called on:
- save
- update
- updateAll
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BlairAllegroTech/js-data-jsonapi/issues/12#issuecomment-229214241, or mute the thread https://github.com/notifications/unsubscribe/AArXmZ-LnOR2riY60hd0iBLv1wse-rJdks5qQa2TgaJpZM4JAGyE .
When you are debugging, can you step into the beforeUpdate
call and see where the code goes?
Try to find out where the attrs gets set to null.
I'm not sure if this is a bug or by design. e.g To fix this do we need to make sure that cb is always set in lifetime events or does adapter.update
need to handle empty attrs
Ok i finally was able to reproduce this. There were a few bugs in the tests i created yesterday.
But the problem was around the way lifecycle events are invoked. It looks as though all lifecycle events are defined statically against resources are 'promisfied ' by js-data.
This test: here
describe('DS#Save', function () { ..});
it('should save data to adapter', ...
Will reproduce the problem when beforeUpdateJsonApiData
does not return data when no callback provided in the call.
There may be a few more things to be tested here:
Thanks @BlairAllegroTech Sorry I didn't help with the investigation of this issue. Glad you were able to sort it.
@rgant No worries at the moment the more feedback i can get the better!
I would be really appreciate any feedback you can give on what works well and what doesn't.
parent.findRelated('relationName')
to load childrenI'll try out version 9 as soon as I can and let you know how it goes. Thanks so much!
I haven't actually gotten to relationships on the client side yet (the server side has many). First thing I was trying was to list, create and update a single model. I'll let you know how that goes.
Version 9 resolves this issue. Thanks again!
After resolving #11 I'm getting this error:
This is the function raising the error:
The error is on this line:
if (attrs[config.idAttribute]) {