add method
Adds a record object to an object store.
Syntax
var retVal = IDBObjectStore.add(value, key);Parameters
- value [in]
-
Type: any
- key [in, optional]
-
Type: any
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 saved to the object store. | |
|
The value specified for the key parameter is not a valid key value. |
|
The object store has been deleted or removed. | |
|
The associated transaction is read-only. |
|
The associated transaction is not active. |
Standards information
Examples
The following example walks through an array and adds non-blank elements to an object store. For more info, see Managing data with transactions.
for (var iIndex = 0; iIndex < this._ImageTags.length; iIndex++) {
var sNewTag = this._ImageTags[ iIndex ];
if ( sNewTag != "" ) {
var oNewTag = { ImageID : this._ImageID, TagWord : sNewTag };
var hReqAddTag = evt.target.source.objectStore.add( oNewTag );
hReqAddTag.onsuccess = handleRequestEvent;
hReqAddTag.onerror = handleRequestEvent;
}
}
See also
Build date: 11/22/2012
