Need to be able to cascade saves.
When I load child objects (such as with parent.loadRelations(['child'])) and modify a property on the child object, I'd like to be able to persist the whole tree at once by calling parent.save(). Since I'm manually (lazy) loading with loadRelations(), perhaps I could also saveRelations()?
Found a gem. Let's say parent hasMany child and child belongsTo parent. Let's also say that in memory, parent.children is a link and child.parent is a link. I'm thinking this should work:
child.save({ with: ['parent']).then(...)
// or
parent.save({ with: ['children'] }).then(...)
Can you try it?
Yes, that does sort of work; it does push data to the server for the related objects. However, using with causes all the data to be sent to one url. This might work if you're coding your backend to split off those objects and store them separately. But, in the case of my mock server, json-server, that will actually store the children objects in two separate places and create data incongruities. I think the relationship would need to keep the resource's uri in order to act accordingly. (e.g. if it was originally retrieved from /parents/1/children, the collection should be put back there)
So you want it to make multiple requests? Yeah, that would require more implementation in JSData.