get method

Retrieves a record from an object store.

Internet Explorer 10



object.get(key, retVal)


key [in]

Type: any

The key value of the record to be retrieved.


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

The key parameter value is not valid.

name: InvalidStateError
code: DOMException.INVALID_STATE_ERR (11)

The object store has been deleted or is otherwise not available.

name: TransactionInactiveError

The associated transaction is not active.


Standards information


This example uses the get method to locate an object store record using the value of an index, rather than the key value. For more info, see Managing data with transactions.

     var aStoreNames = [ "ImageDetails", "ImageTags" ];
     var hTransaction = hDBHandle.transaction( aStoreNames, "readonly" );
     var hDetails = hTransaction.objectStore( "ImageDetails" );
     var hIdxImage = hDetails.index( "IxImagesByName" );
     var hImageReq = hIdxImage.get( sFilename );
     hImageReq.onsuccess = function( evt ) {

        var oDetails =;
        if ( oDetails == null ) {
          // No details were found for the image, so create
          // defaults to show to the user.
          oDetails = { "ImageTitle" : "<Untitled Image>",
                       "ImageDesc" : "<No description>" };
         updateFormData( oDetails );

See also