Closed cboulay closed 12 years ago
I should take care of #53 before doing this otherwise I will end up redoing a lot of it.
The toJSON function for each model with associated (child) models should remove those models but retain the child models' ids. Then we only have to worry about updating _id, not the attached models. I think I still need to use an "associations" attribute, as opposed to searching for attributes that end in _id, because I need to know what database table to get the id from.
If you create a game then create an event but do so before the server has returned the id for the game, then the event will be created with a event.game_id equal to the game.local_id. This is fine for local storage, but of course the API won't accept that game_id when posting the event. The AJAX sync'ing is done in order, so the game will have an appropriate game.id before the event is sync'd, but there needs to be a way to set event.game_id = game.id instead of event.game_id = game.local_id. I'm thinking a general solution might be to define these types of associations in the model definition then when syncing a model with such associations defined we can first check the local WebSQL database to see if the associated model (e.g. game) has a legit id.