put method
Replaces or adds a record object in an object store.
Syntax
var retVal = IDBObjectStore.put(value, key);Parameters
- value [in]
-
Type: any
An object literal containing the values to be stored in the object store.
- key [in, optional]
-
Type: any
The key value of the new record.
Exceptions
This method can throw the following DOMException exceptions:
Note As of a Windows Store app using JavaScript, the code property is deprecated in favor of the name property, which is preferred for standards compliance and future compatibility.
| Exception properties | Condition |
|---|---|
|
The data could not be stored. | |
|
The specified key value is invalid or the value specified for an indexed attribute is invalid. |
|
The data source has been deleted or is otherwise not available. | |
|
The associated transaction is read-only. |
|
The associated transaction is not active. |
Standards information
Examples
The following example creates an object store and then uses the put method to populate it.
oStore = dbHandle.createObjectStore( "ImageTags", oOptions );
var aImageTags = getInitialTags();
for ( var x = 0; x < aImageTags.length; x++ ) {
var hRequest = oStore.put( aImageTags[ x ] );
hRequest.onsuccess = handleRequestEvent;
hRequest.onerror = handleRequestEvent;
}
See also
Build date: 11/22/2012
