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 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

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

IDBObjectStore

 

 

Show:
© 2014 Microsoft