add method

Adds a record object to an object store.

Internet Explorer 10



var retVal = IDBObjectStore.add(value, key);


value [in]

Type: any

key [in, optional]

Type: any


This method can throw the following DOMException exceptions:

Note  As of Internet Explorer 10, the code property is deprecated in favor of the name property, which is preferred for standards compliance and future compatibility.
Exception propertiesCondition
name: DataCloneError
code: DOMException.DATA_CLONE_ERR (25)

The data could not be saved to the object store.

name: DataError

The value specified for the key parameter is not a valid key value.

name: InvalidStateError
code: DOMException.INVALID_STATE_ERR (11)

The object store has been deleted or removed.

name: ReadOnlyError

The associated transaction is read-only.

name: TransactionInactiveError

The associated transaction is not active.


Standards information


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 = oNewTag );
                         hReqAddTag.onsuccess = handleRequestEvent;
                         hReqAddTag.onerror = handleRequestEvent;

See also