ObjectStore.hx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. // This file is generated from mozilla\IDBObjectStore.webidl. Do not edit!
  23. package js.html.idb;
  24. /**
  25. This example shows a variety of different uses of object stores, from updating the data structure with `IDBObjectStore.createIndex` inside an `onupgradeneeded` function, to adding a new item to our object store with `IDBObjectStore.add`. For a full working example, see our To-do Notifications app (view example live.)
  26. Documentation [IDBObjectStore](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
  27. @see <https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore>
  28. **/
  29. @:native("IDBObjectStore")
  30. extern class ObjectStore {
  31. /**
  32. The name of this object store.
  33. **/
  34. var name : String;
  35. /**
  36. The key path of this object store. If this attribute is `null`, the application must provide a key for each modification operation.
  37. **/
  38. var keyPath(default,null) : Dynamic;
  39. /**
  40. A list of the names of indexes on objects in this object store.
  41. **/
  42. var indexNames(default,null) : js.html.DOMStringList;
  43. /**
  44. The `IDBTransaction` object to which this object store belongs.
  45. **/
  46. var transaction(default,null) : Transaction;
  47. /**
  48. The value of the auto increment flag for this object store.
  49. **/
  50. var autoIncrement(default,null) : Bool;
  51. /**
  52. Returns an `IDBRequest` object, and, in a separate thread, creates a structured clone of the `value`, and stores the cloned value in the object store. This is for updating existing records in an object store when the transaction's mode is `readwrite`.
  53. @throws DOMError
  54. **/
  55. function put( value : Dynamic, ?key : Dynamic ) : Request;
  56. /**
  57. Returns an `IDBRequest` object, and, in a separate thread, creates a structured clone of the `value`, and stores the cloned value in the object store. This is for adding new records to an object store.
  58. @throws DOMError
  59. **/
  60. function add( value : Dynamic, ?key : Dynamic ) : Request;
  61. /**
  62. returns an `IDBRequest` object, and, in a separate thread, deletes the store object selected by the specified key. This is for deleting individual records out of an object store.
  63. @throws DOMError
  64. **/
  65. function delete( key : Dynamic ) : Request;
  66. /**
  67. Returns an `IDBRequest` object, and, in a separate thread, returns the store object store selected by the specified key. This is for retrieving specific records from an object store.
  68. @throws DOMError
  69. **/
  70. function get( key : Dynamic ) : Request;
  71. /**
  72. Returns an `IDBRequest` object, and, in a separate thread retrieves and returns the record key for the object in the object stored matching the specified parameter.
  73. @throws DOMError
  74. **/
  75. function getKey( key : Dynamic ) : Request;
  76. /**
  77. Creates and immediately returns an `IDBRequest` object, and clears this object store in a separate thread. This is for deleting all current records out of an object store.
  78. @throws DOMError
  79. **/
  80. function clear() : Request;
  81. /**
  82. Returns an `IDBRequest` object, and, in a separate thread, returns a new `IDBCursorWithValue` object. Used for iterating through an object store by primary key with a cursor.
  83. @throws DOMError
  84. **/
  85. function openCursor( ?range : Dynamic, direction : CursorDirection = NEXT ) : Request;
  86. /**
  87. Creates a new index during a version upgrade, returning a new `IDBIndex` object in the connected database.
  88. @throws DOMError
  89. **/
  90. @:overload( function( name : String, keyPath : Array<String>, ?optionalParameters : IndexParameters) : Index {} )
  91. function createIndex( name : String, keyPath : String, ?optionalParameters : IndexParameters ) : Index;
  92. /**
  93. Opens an index from this object store after which it can, for example, be used to return a sequence of records sorted by that index using a cursor.
  94. @throws DOMError
  95. **/
  96. function index( name : String ) : Index;
  97. /**
  98. Destroys the specified index in the connected database, used during a version upgrade.
  99. @throws DOMError
  100. **/
  101. function deleteIndex( indexName : String ) : Void;
  102. /**
  103. Returns an `IDBRequest` object, and, in a separate thread, returns the total number of records that match the provided key or `IDBKeyRange`. If no arguments are provided, it returns the total number of records in the store.
  104. @throws DOMError
  105. **/
  106. function count( ?key : Dynamic ) : Request;
  107. /**
  108. Returns an `IDBRequest` object retrieves all objects in the object store matching the specified parameter or all objects in the store if no parameters are given.
  109. @throws DOMError
  110. **/
  111. function getAll( ?key : Dynamic, ?limit : Int ) : Request;
  112. /**
  113. Returns an `IDBRequest` object retrieves record keys for all objects in the object store matching the specified parameter or all objects in the store if no parameters are given.
  114. @throws DOMError
  115. **/
  116. function getAllKeys( ?key : Dynamic, ?limit : Int ) : Request;
  117. /**
  118. Returns an `IDBRequest` object, and, in a separate thread, returns a new `IDBCursor`. Used for iterating through an object store with a key.
  119. @throws DOMError
  120. **/
  121. function openKeyCursor( ?range : Dynamic, direction : CursorDirection = NEXT ) : Request;
  122. }