This class defines the API that other Stores have to implement to assure a coherent API.
It also implements some validations and functionality that is the same across store impnementations
set store.hoodie instance variable
creates or replaces an an eventually existing object in the store with same type & id.
When id is undefined, it gets generated and a new object gets saved
example usage:
store.save('car', undefined, {color: 'red'})
store.save('car', 'abc4567', {color: 'red'})
validations
.add is an alias for .save, with the difference that there is no id argument.
Internally it simply calls `.save(type, undefined, object).
In contrast to .save, the .update method does not replace the stored object,
but only changes the passed attributes of an exsting object, if it exists
both a hash of key/values or a function that applies the update to the passed object can be passed.
example usage
hoodie.store.update('car', 'abc4567', {sold: true}) hoodie.store.update('car', 'abc4567', function(obj) { obj.sold = true })
normalize input
check if something changed
workaround for undefined values, as $.extend ignores these
apply update
if not found, add it
update all objects in the store, can be optionally filtered by a function As an alternative, an array of objects can be passed
example usage
hoodie.store.updateAll()
normalize the input: make sure we have all objects
now we update all objects one by one and return a promise that will be resolved once all updates have been finished
loads one object from Store, specified by type and id
example usage:
store.find('car', 'abc4567')
returns all objects from store. Can be optionally filtered by a type or a function
Removes one object specified by type and id.
when object has been synced before, mark it as deleted. Otherwise remove it from Store.
Destroyes all objects. Can be filtered by a type
/ not allowed for id
/ not allowed for type
Store