-
Notifications
You must be signed in to change notification settings - Fork 61
Data Manipulation
Use the following methods to read and write data (all methods in this section return the IDBTransaction they open):
put(/*Object*/ dataObj, /*Function?*/onSuccess, /*Function?*/onError)dataObj is the Object to store. onSuccess will be called when the insertion/update was successful,
and it will receive the keyPath value (the id, so to say) of the inserted object as first and only
argument. onError will be called if the insertion/update failed and it will receive the error event
object as first and only argument. If the store already contains an object with the given keyPath id,
it will be overwritten by dataObj.
Out-of-line Keys
If you use out-of-line keys in your store, you must provide a key as first argument to the put method:
put(/*Anything*/ key, /*Object*/ dataObj, /*Function?*/onSuccess, /*Function?*/onError)The onSuccess and onError arguments remain optional.
get(/*keyPath value*/ key, /*Function?*/onSuccess, /*Function?*/onError)key is the keyPath property value (the id) of the object to retrieve. onSuccess will be called if
the get operation was successful, and it will receive the stored object as first and only argument. If
no object was found with the given keyPath value, this argument will be null. onError will be called
if the get operation failed and it will receive the error event object as first and only argument.
getAll(/*Function?*/onSuccess, /*Function?*/onError)onSuccess will be called if the getAll operation was successful, and it will receive an Array of
all objects currently stored in the store as first and only argument. onError will be called if
the getAll operation failed and it will receive the error event object as first and only argument.
remove(/*keyPath value*/ key, /*Function?*/onSuccess, /*Function?*/onError)key is the keyPath property value (the id) of the object to remove. onSuccess will be called if
the remove operation was successful, and it should receive false as first and only argument if the
object to remove was not found, and true if it was found and removed.
NOTE: FF 8 will pass the key to the onSuccess handler, no matter if there is an corresponding object
or not. Chrome 15 will pass null if removal was successful, and call the error handler if the object
wasn't found. Chrome 17+ will behave as described above.
onError will be called if the remove operation failed and it will receive the error event object as first
and only argument.
clear(/*Function?*/onSuccess, /*Function?*/onError)onSuccess will be called if the clear operation was successful. onError will be called if the clear
operation failed and it will receive the error event object as first and only argument.