1,007
edits
No edit summary |
|||
Line 148: | Line 148: | ||
__proto__: Store.prototype, | __proto__: Store.prototype, | ||
_logName: "foo", | _logName: "foo", | ||
itemExists: function( | itemExists: function(guid) { | ||
// Return true if an item with guid | // Return true if an item with given guid exists in the store. | ||
}, | }, | ||
createRecord: function( | createRecord: function(guid) { | ||
// this | // Return the cached one if we have it: | ||
// | let record = this.cache.get(guid); | ||
// | if (record) | ||
return record; | |||
// Otherwise, instantiate: | |||
record = new FooRecord(); | |||
// Set the data and the guid on it: | |||
record.bar = 17; // or whatever | |||
record.id = guid; | |||
// Add it to the cache: | |||
this.cache.put(guid, record); | |||
// return the record | // return the record | ||
return record; | |||
}, | }, | ||
changeItemId: function(oldId, newId) { | changeItemId: function(oldId, newId) { | ||
Line 164: | Line 170: | ||
}, | }, | ||
getAllIds: function() { | getAllIds: function() { | ||
// Return a | // Return a list of the GUIDs of all items | ||
}, | }, | ||
wipe: function() { | wipe: function() { | ||
Line 170: | Line 176: | ||
}, | }, | ||
create: function(record) { | create: function(record) { | ||
// Create a new item based on the values in record | |||
}, | }, | ||
update: function(record) { | update: function(record) { | ||
// look up the stored record with id = record.id, then set | |||
// its values to those of new record | |||
}, | }, | ||
remove: function(record) { | remove: function(record) { | ||
// look up the stored record with id = record.id, then delete it. | |||
} | } | ||
}; | }; |
edits