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. interface IDBVersionChangeEvent : Event {
  28. constructor(DOMString type, optional IDBVersionChangeEventInit eventInitDict = {});
  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 mixin 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. Promise<sequence<IDBDatabaseInfo>> databases();
  49.  
  50. short cmp(any first, any second);
  51. };
  52.  
  53. dictionary IDBDatabaseInfo {
  54. DOMString name;
  55. unsigned long long version;
  56. };
  57.  
  58. [Exposed=(Window,Worker)]
  59. interface IDBDatabase : EventTarget {
  60. readonly attribute DOMString name;
  61. readonly attribute unsigned long long version;
  62. readonly attribute DOMStringList objectStoreNames;
  63.  
  64. [NewObject] IDBTransaction transaction((DOMString or sequence<DOMString>) storeNames,
  65. optional IDBTransactionMode mode = "readonly",
  66. optional IDBTransactionOptions options = {});
  67. void close();
  68.  
  69. [NewObject] IDBObjectStore createObjectStore(
  70. DOMString name,
  71. optional IDBObjectStoreParameters options = {});
  72. void deleteObjectStore(DOMString name);
  73.  
  74. // Event handlers:
  75. attribute EventHandler onabort;
  76. attribute EventHandler onclose;
  77. attribute EventHandler onerror;
  78. attribute EventHandler onversionchange;
  79. };
  80.  
  81. enum IDBTransactionDurability { "default", "strict", "relaxed" };
  82.  
  83. dictionary IDBTransactionOptions {
  84. IDBTransactionDurability durability = "default";
  85. };
  86.  
  87. dictionary IDBObjectStoreParameters {
  88. (DOMString or sequence<DOMString>)? keyPath = null;
  89. boolean autoIncrement = false;
  90. };
  91.  
  92. [Exposed=(Window,Worker)]
  93. interface IDBObjectStore {
  94. attribute DOMString name;
  95. readonly attribute any keyPath;
  96. readonly attribute DOMStringList indexNames;
  97. [SameObject] readonly attribute IDBTransaction transaction;
  98. readonly attribute boolean autoIncrement;
  99.  
  100. [NewObject] IDBRequest put(any value, optional any key);
  101. [NewObject] IDBRequest add(any value, optional any key);
  102. [NewObject] IDBRequest delete(any query);
  103. [NewObject] IDBRequest clear();
  104. [NewObject] IDBRequest get(any query);
  105. [NewObject] IDBRequest getKey(any query);
  106. [NewObject] IDBRequest getAll(optional any query,
  107. optional [EnforceRange] unsigned long count);
  108. [NewObject] IDBRequest getAllKeys(optional any query,
  109. optional [EnforceRange] unsigned long count);
  110. [NewObject] IDBRequest count(optional any query);
  111.  
  112. [NewObject] IDBRequest openCursor(optional any query,
  113. optional IDBCursorDirection direction = "next");
  114. [NewObject] IDBRequest openKeyCursor(optional any query,
  115. optional IDBCursorDirection direction = "next");
  116.  
  117. IDBIndex index(DOMString name);
  118.  
  119. [NewObject] IDBIndex createIndex(DOMString name,
  120. (DOMString or sequence<DOMString>) keyPath,
  121. optional IDBIndexParameters options = {});
  122. void deleteIndex(DOMString name);
  123. };
  124.  
  125. dictionary IDBIndexParameters {
  126. boolean unique = false;
  127. boolean multiEntry = false;
  128. };
  129.  
  130. [Exposed=(Window,Worker)]
  131. interface IDBIndex {
  132. attribute DOMString name;
  133. [SameObject] readonly attribute IDBObjectStore objectStore;
  134. readonly attribute any keyPath;
  135. readonly attribute boolean multiEntry;
  136. readonly attribute boolean unique;
  137.  
  138. [NewObject] IDBRequest get(any query);
  139. [NewObject] IDBRequest getKey(any query);
  140. [NewObject] IDBRequest getAll(optional any query,
  141. optional [EnforceRange] unsigned long count);
  142. [NewObject] IDBRequest getAllKeys(optional any query,
  143. optional [EnforceRange] unsigned long count);
  144. [NewObject] IDBRequest count(optional any query);
  145.  
  146. [NewObject] IDBRequest openCursor(optional any query,
  147. optional IDBCursorDirection direction = "next");
  148. [NewObject] IDBRequest openKeyCursor(optional any query,
  149. optional IDBCursorDirection direction = "next");
  150. };
  151.  
  152. [Exposed=(Window,Worker)]
  153. interface IDBKeyRange {
  154. readonly attribute any lower;
  155. readonly attribute any upper;
  156. readonly attribute boolean lowerOpen;
  157. readonly attribute boolean upperOpen;
  158.  
  159. // Static construction methods:
  160. [NewObject] static IDBKeyRange only(any value);
  161. [NewObject] static IDBKeyRange lowerBound(any lower, optional boolean open = false);
  162. [NewObject] static IDBKeyRange upperBound(any upper, optional boolean open = false);
  163. [NewObject] static IDBKeyRange bound(any lower,
  164. any upper,
  165. optional boolean lowerOpen = false,
  166. optional boolean upperOpen = false);
  167.  
  168. boolean includes(any key);
  169. };
  170.  
  171. [Exposed=(Window,Worker)]
  172. interface IDBCursor {
  173. readonly attribute (IDBObjectStore or IDBIndex) source;
  174. readonly attribute IDBCursorDirection direction;
  175. readonly attribute any key;
  176. readonly attribute any primaryKey;
  177. [SameObject] readonly attribute IDBRequest request;
  178.  
  179. void advance([EnforceRange] unsigned long count);
  180. void continue(optional any key);
  181. void continuePrimaryKey(any key, any primaryKey);
  182.  
  183. [NewObject] IDBRequest update(any value);
  184. [NewObject] IDBRequest delete();
  185. };
  186.  
  187. enum IDBCursorDirection {
  188. "next",
  189. "nextunique",
  190. "prev",
  191. "prevunique"
  192. };
  193.  
  194. [Exposed=(Window,Worker)]
  195. interface IDBCursorWithValue : IDBCursor {
  196. readonly attribute any value;
  197. };
  198.  
  199. [Exposed=(Window,Worker)]
  200. interface IDBTransaction : EventTarget {
  201. readonly attribute DOMStringList objectStoreNames;
  202. readonly attribute IDBTransactionMode mode;
  203. readonly attribute IDBTransactionDurability durability;
  204. [SameObject] readonly attribute IDBDatabase db;
  205. readonly attribute DOMException? error;
  206.  
  207. IDBObjectStore objectStore(DOMString name);
  208. void commit();
  209. void abort();
  210.  
  211. // Event handlers:
  212. attribute EventHandler onabort;
  213. attribute EventHandler oncomplete;
  214. attribute EventHandler onerror;
  215. };
  216.  
  217. enum IDBTransactionMode {
  218. "readonly",
  219. "readwrite",
  220. "versionchange"
  221. };
  222.