This project has moved. For the latest updates, please go here.

count

The count function counts the number of objects present for a given key.

Parameters

  • source:
    • An object store, an object store promise object, an index or an index promise object
  • key:
    • A key or keyRange as filter on an index.
    • Optional
      • Default: undefined

Returns

The function returns a promise object with 2 callbacks
  • Success callback
    • The count is successfully
    • The first argument contains the number of objects for the given key.
    • The second argument contains the transaction.
    • The third argument contains the original indexeddb event arguments
  • Error callback
    • Retrieving data failed
    • The argument object contains a custom error object.

Errors

  • DataError
    • The provided key isn't a valid key or key range.
  • TransactionInactiveError
    • You are trying to open a cursor outside or on an inactive transaction.
  • InvalidStateError
    • You are trying to modify data on a removed object store.

Example

var dbpromise = linq2indexedDB.core.db("name", 1);
var transactionPromise = linq2indexedDB.core.transaction(dbpromise, ["objectstore"]);
var objectStorePromise = linq2indexedDB.core.objectStore(transactionPromise, "objectstore");
linq2indexedDB.core.get(objectStorePromise, 1).then(success, error);
function success(args){
   var data = args[0]; 
   var transaction= args[1];
   var orignalevent = args[2];
}
function error(args){
   var error= args;
}

Last edited Feb 11, 2014 at 6:29 PM by KDegrave, version 2

Comments

No comments yet.