delete method

Deletes a record object from an object store.

Syntax

var retVal = IDBObjectStore.delete(key);

Parameters

key [in]

Type: any

The key value of the record object to be deleted.

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

The associated transaction is read-only.

name: TransactionInactiveError

The associated transaction has closed or is not active.

Standards information

Examples

The following example is taken from a success event handler; it deletes a record from an object store if the value associated with the record is not part of an array. For more info, see Managing data with transactions.


                var oCursor = evt.target.result;
                if ( oCursor ) { 
      
                   var sTag = oCursor.value.TagWord;
                   var iIndexNo = this._ImageTags.indexOf( sTag );
                   if ( iIndexNo == -1 ) {
                      var hReqDelTag = oCursor.source.objectStore.delete( oCursor.primaryKey );
                      hReqDelTag.onsuccess = handleRequestEvent;
                      hReqDelTag.onerror = handleRequestEvent;
                   } else {
                      this._ImageTags[ iIndexNo ] = "";   
                   }
                   oCursor.continue();


See also

IDBObjectStore

 

 

Show:
© 2014 Microsoft. All rights reserved.