MDN will be in maintenance mode on Friday September 22nd, starting at 10 AM Pacific / 5 PM UTC, for about 1 hour.


The continuePrimaryKey() method of the IDBCursor interface advances the cursor to the to the item whose key matches the key parameter as well as whose primary key matches the primary key parameter.

A typical use case, is to resume the iteration where a previous cursor has been closed, without having to compare the keys one by one.

Calling this method more than once before new cursor data has been loaded - for example, calling continuePrimaryKey() twice from the same onsuccess handler - results in an InvalidStateError being thrown on the second call because the cursor’s got value flag has been unset.

Note: This feature is available in Web Workers.


cursor.continuePrimaryKey(key, primaryKey);


The key to position the cursor at.
The primary key to position the cursor at.

Return value



This method may raise a DOMException of one of the following types:

Exception Description
TransactionInactiveError This IDBCursor's transaction is inactive.

The key parameter may have any of the following conditions:

  • The key is not a valid key.
  • The key is less than or equal to this cursor's position and the cursor's direction is next or nextunique.
  • The key is greater than or equal to this cursor's position and this cursor's direction is prev or prevunique.
InvalidStateError The cursor is currently being iterated or has iterated past its end.
InvalidAccessError The cursor's direction is not prev or next.


here’s how you can resume an iteration of all articles tagged with 'javascript' since your last visit:

let request = articleStore.index("tag").openCursor();
let count = 0;
let unreadList = [];
request.onsuccess = (event) => {
    let cursor =;
    if (!cursor) { return; }
    let lastPrimaryKey = getLastIteratedArticleId();
    if (lastPrimaryKey > cursor.primaryKey) {
      cursor.continuePrimaryKey("javascript", lastPrimaryKey);
    // update lastIteratedArticleId
    // preload 5 articles into the unread list;
    if (++count < 5) {


Specification Status Comment
Indexed Database API 2.0
The definition of 'continuePrimaryKey()' in that specification.
Editor's Draft Initial definition.
Indexed Database API 2.0
The definition of 'continuePrimaryKey()' in that specification.
Editor's Draft  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 58 10 moz
51.0 (51.0)
? 45 ?
Feature Android Webview Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 58 58 51.0 (51.0) ? 45 ?

See also

Document Tags and Contributors

 Contributors to this page: jpmedley, sangwhan, teoli
 Last updated by: jpmedley,