sproutcore/sproutcore — pull request #1161 by mirion (2014-01-11 01:53:09+00:00)
Title: Add support for record patching using a partial (containing only a subset of attributes) or complete data hash

The current version of datastore doesn't offer support for record patching via partial data hashes. A typical example is the following:
1. a new record is created
2. the record is sent to the server
3. the server saves data into the database
4. the server answers with some fields, for example an unique id that can't be calculated by the client

We have the possibility to send from the server the complete record, but this would be a waste of resources and may be even expensive in terms of computing resources.

This patching function is based on and using pushRetrieve. It mainly merges the two data hashes, the new (partial or also full) and the existing one but always the new data is preferred. Once merge done, the resulting hash is pushRetrieve-d into the store. As pushRetrieve, the merge should be done only when the record is not dirty and since pushRetrieve takes care of this, it should handle only READY_CLEAN.

Due to the logic of this function, in most of the cases, it can be safely used in place of pushRetrieve. In fact, I'm using it exclusively (in place of pushRetrieve) for some months now and never had any undesired side effect.