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 propertiesCondition
name: DataCloneError
code: DOMException.DATA_CLONE_ERR (25)

The data could not be stored.

name: DataError

The specified key value is invalid or the value specified for an indexed attribute is invalid.

name: InvalidStateError
code: DOMException.INVALID_STATE_ERR (11)

The data source has been deleted or is otherwise not available.

name: ReadOnlyError

The associated transaction is read-only.

name: TransactionInactiveError

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

IDBObjectStore

 

 

Show:
© 2014 Microsoft. All rights reserved.