IDL Index

  1. [Exposed=(Window,Worker)]
  2. interface IDBRequest : EventTarget {
  3. readonly attribute any result;
  4. readonly attribute DOMException? error;
  5. readonly attribute (IDBObjectStore or IDBIndex or IDBCursor)? source;
  6. readonly attribute IDBTransaction? transaction;
  7. readonly attribute IDBRequestReadyState readyState;
  8.  
  9. // Event handlers:
  10. attribute EventHandler onsuccess;
  11. attribute EventHandler onerror;
  12. };
  13.  
  14. enum IDBRequestReadyState {
  15. "pending",
  16. "done"
  17. };
  18.  
  19. [Exposed=(Window,Worker)]
  20. interface IDBOpenDBRequest : IDBRequest {
  21. // Event handlers:
  22. attribute EventHandler onblocked;
  23. attribute EventHandler onupgradeneeded;
  24. };
  25.  
  26. [Exposed=(Window,Worker),
  27. Constructor(DOMString type, optional IDBVersionChangeEventInit eventInitDict)]
  28. interface IDBVersionChangeEvent : Event {
  29. readonly attribute unsigned long long oldVersion;
  30. readonly attribute unsigned long long? newVersion;
  31. };
  32.  
  33. dictionary IDBVersionChangeEventInit : EventInit {
  34. unsigned long long oldVersion = 0;
  35. unsigned long long? newVersion = null;
  36. };
  37.  
  38. partial interface WindowOrWorkerGlobalScope {
  39. [SameObject] readonly attribute IDBFactory indexedDB;
  40. };
  41.  
  42. [Exposed=(Window,Worker)]
  43. interface IDBFactory {
  44. [NewObject] IDBOpenDBRequest open(DOMString name,
  45. optional [EnforceRange] unsigned long long version);
  46. [NewObject] IDBOpenDBRequest deleteDatabase(DOMString name);
  47.  
  48. short cmp(any first, any second);
  49. };
  50.  
  51. [Exposed=(Window,Worker)]
  52. interface IDBDatabase : EventTarget {
  53. readonly attribute DOMString name;
  54. readonly attribute unsigned long long version;
  55. readonly attribute DOMStringList objectStoreNames;
  56.  
  57. [NewObject] IDBTransaction transaction((DOMString or sequence<DOMString>) storeNames,
  58. optional IDBTransactionMode mode = "readonly");
  59. void close();
  60.  
  61. [NewObject] IDBObjectStore createObjectStore(DOMString name,
  62. optional IDBObjectStoreParameters options);
  63. void deleteObjectStore(DOMString name);
  64.  
  65. // Event handlers:
  66. attribute EventHandler onabort;
  67. attribute EventHandler onclose;
  68. attribute EventHandler onerror;
  69. attribute EventHandler onversionchange;
  70. };
  71.  
  72. dictionary IDBObjectStoreParameters {
  73. (DOMString or sequence<DOMString>)? keyPath = null;
  74. boolean autoIncrement = false;
  75. };
  76.  
  77. [Exposed=(Window,Worker)]
  78. interface IDBObjectStore {
  79. attribute DOMString name;
  80. readonly attribute any keyPath;
  81. readonly attribute DOMStringList indexNames;
  82. [SameObject] readonly attribute IDBTransaction transaction;
  83. readonly attribute boolean autoIncrement;
  84.  
  85. [NewObject] IDBRequest put(any value, optional any key);
  86. [NewObject] IDBRequest add(any value, optional any key);
  87. [NewObject] IDBRequest delete(any query);
  88. [NewObject] IDBRequest clear();
  89. [NewObject] IDBRequest get(any query);
  90. [NewObject] IDBRequest getKey(any query);
  91. [NewObject] IDBRequest getAll(optional any query,
  92. optional [EnforceRange] unsigned long count);
  93. [NewObject] IDBRequest getAllKeys(optional any query,
  94. optional [EnforceRange] unsigned long count);
  95. [NewObject] IDBRequest count(optional any query);
  96.  
  97. [NewObject] IDBRequest openCursor(optional any query,
  98. optional IDBCursorDirection direction = "next");
  99. [NewObject] IDBRequest openKeyCursor(optional any query,
  100. optional IDBCursorDirection direction = "next");
  101.  
  102. IDBIndex index(DOMString name);
  103.  
  104. [NewObject] IDBIndex createIndex(DOMString name,
  105. (DOMString or sequence<DOMString>) keyPath,
  106. optional IDBIndexParameters options);
  107. void deleteIndex(DOMString name);
  108. };
  109.  
  110. dictionary IDBIndexParameters {
  111. boolean unique = false;
  112. boolean multiEntry = false;
  113. };
  114.  
  115. [Exposed=(Window,Worker)]
  116. interface IDBIndex {
  117. attribute DOMString name;
  118. [SameObject] readonly attribute IDBObjectStore objectStore;
  119. readonly attribute any keyPath;
  120. readonly attribute boolean multiEntry;
  121. readonly attribute boolean unique;
  122.  
  123. [NewObject] IDBRequest get(any query);
  124. [NewObject] IDBRequest getKey(any query);
  125. [NewObject] IDBRequest getAll(optional any query,
  126. optional [EnforceRange] unsigned long count);
  127. [NewObject] IDBRequest getAllKeys(optional any query,
  128. optional [EnforceRange] unsigned long count);
  129. [NewObject] IDBRequest count(optional any query);
  130.  
  131. [NewObject] IDBRequest openCursor(optional any query,
  132. optional IDBCursorDirection direction = "next");
  133. [NewObject] IDBRequest openKeyCursor(optional any query,
  134. optional IDBCursorDirection direction = "next");
  135. };
  136.  
  137. [Exposed=(Window,Worker)]
  138. interface IDBKeyRange {
  139. readonly attribute any lower;
  140. readonly attribute any upper;
  141. readonly attribute boolean lowerOpen;
  142. readonly attribute boolean upperOpen;
  143.  
  144. // Static construction methods:
  145. [NewObject] static IDBKeyRange only(any value);
  146. [NewObject] static IDBKeyRange lowerBound(any lower, optional boolean open = false);
  147. [NewObject] static IDBKeyRange upperBound(any upper, optional boolean open = false);
  148. [NewObject] static IDBKeyRange bound(any lower,
  149. any upper,
  150. optional boolean lowerOpen = false,
  151. optional boolean upperOpen = false);
  152.  
  153. boolean _includes(any key);
  154. };
  155.  
  156. [Exposed=(Window,Worker)]
  157. interface IDBCursor {
  158. readonly attribute (IDBObjectStore or IDBIndex) source;
  159. readonly attribute IDBCursorDirection direction;
  160. readonly attribute any key;
  161. readonly attribute any primaryKey;
  162.  
  163. void advance([EnforceRange] unsigned long count);
  164. void continue(optional any key);
  165. void continuePrimaryKey(any key, any primaryKey);
  166.  
  167. [NewObject] IDBRequest update(any value);
  168. [NewObject] IDBRequest delete();
  169. };
  170.  
  171. enum IDBCursorDirection {
  172. "next",
  173. "nextunique",
  174. "prev",
  175. "prevunique"
  176. };
  177.  
  178. [Exposed=(Window,Worker)]
  179. interface IDBCursorWithValue : IDBCursor {
  180. readonly attribute any value;
  181. };
  182.  
  183. [Exposed=(Window,Worker)]
  184. interface IDBTransaction : EventTarget {
  185. readonly attribute DOMStringList objectStoreNames;
  186. readonly attribute IDBTransactionMode mode;
  187. [SameObject] readonly attribute IDBDatabase db;
  188. readonly attribute DOMException error;
  189.  
  190. IDBObjectStore objectStore(DOMString name);
  191. void abort();
  192.  
  193. // Event handlers:
  194. attribute EventHandler onabort;
  195. attribute EventHandler oncomplete;
  196. attribute EventHandler onerror;
  197. };
  198.  
  199. enum IDBTransactionMode {
  200. "readonly",
  201. "readwrite",
  202. "versionchange"
  203. };
  204.