Changes

Jump to: navigation, search

CloudServices/Sync/FxSync/Developer/ClientAPI

1,312 bytes added, 21:50, 30 January 2009
Writing a Store class
// ...
let newGuid = Utils.makeGUID();
 
You can assign GUIDs to items in whatever way you see fit, as long as you are consistent with the mapping. It's entirely up to your Store class to define and maintain this mapping. Also keep in mind that although the data will be encrypted on the server, the GUIDs are public, so don't put passwords into them or anything.
Your Store class '''must''' implement the following methods:
Must return an iterable list containing the GUIDs of every item being stored on the local system. This can be a dictionary-type object where the keys are the GUIDs and the values are whatever; or it can simply be a list of GUIDs.
 
This is the method that the engine will call the first time it syncs, in order to get a complete inventory of what data there is that will need to be uploaded to the server. Unless the items you're syncing have their own inherent GUIDs already defined, you'll need to invent GUIDs for all your items at this time. When one of these GUIDs is later passed as an argument to <tt>createRecord()</tt>, you need to return a record based on the matching data. Therefore, it's the responsibility of this method to define the guid -> item mapping, and to store it for later reference by other methods.
=== createMetaRecords(guid, items) ===
<tt>remove(record)</tt>
:The argument is a record which has been remotely deleted; your Store should locate the matching local item and delete it. (Don't rely on the record that is passed in to this method having any of its attributes set correctly except for <tt>.id</tt>. The <tt>.id</tt> should be al you need, anyway.)
=== Example Store class skeleton ===
// Otherwise, instantiate:
record = new FooRecord();
// Look up the data corresponding to this guid, by the mapping // you've defined. // Set the data and the guid on itthe new record:
record.bar = 17; // or whatever
record.id = guid;
},
getAllIds: function() {
// Return a list of the GUIDs of all items. Invent GUIDs for any items // that don't have them already, and remember the mapping for later use.
},
wipe: function() {
1,007
edits

Navigation menu