/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIIDBObjectStore;
interface nsIIDBRequest;

/**
 * IDBIndex interface.  See
 * http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBIndex for more
 * information.
 */
[scriptable, builtinclass, uuid(a859747a-0f05-4dfb-8f42-05c61415d4e4)]
interface nsIIDBIndex : nsISupports
{
  readonly attribute DOMString name;

  readonly attribute DOMString storeName;

  [implicit_jscontext]
  readonly attribute jsval keyPath;

  readonly attribute boolean unique;

  readonly attribute boolean multiEntry;

  readonly attribute nsIIDBObjectStore objectStore;

  [implicit_jscontext]
  nsIIDBRequest
  get(in jsval key);

  [implicit_jscontext]
  nsIIDBRequest
  getKey(in jsval key);

  [implicit_jscontext, optional_argc]
  nsIIDBRequest
  getAll([optional /* null */] in jsval key,
         [optional /* unlimited */] in unsigned long limit);

  [implicit_jscontext, optional_argc]
  nsIIDBRequest
  getAllKeys([optional /* null */] in jsval key,
             [optional /* unlimited */] in unsigned long limit);

  // direction can be "next", "nextunique", "prev" or "prevunique"
  [implicit_jscontext, optional_argc]
  nsIIDBRequest
  openCursor([optional /* null */] in jsval key,
             [optional /* "next" */] in DOMString direction);

  // direction can be "next", "nextunique", "prev" or "prevunique"
  [implicit_jscontext, optional_argc]
  nsIIDBRequest
  openKeyCursor([optional /* null */] in jsval key,
                [optional /* "next" */] in DOMString direction);

  // Accepts null, a key value, or a nsIIDBKeyRange object.
  [implicit_jscontext, optional_argc]
  nsIIDBRequest
  count([optional] in jsval key);
};
