js.web.indexeddb.IDBObjectStore Maven / Gradle / Ivy
package js.web.indexeddb;
import js.lang.Any;
import js.lang.JsNumber;
import js.lang.Unknown;
import js.util.collections.Array;
import js.util.iterable.StringIterable;
import js.web.dom.DOMStringList;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSByRef;
import org.teavm.jso.JSProperty;
import javax.annotation.Nullable;
/**
* 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.)
*/
public interface IDBObjectStore extends Any {
@JSBody(script = "return IDBObjectStore.prototype")
static IDBObjectStore prototype() {
throw new UnsupportedOperationException("Available only in JavaScript");
}
@JSBody(script = "return new IDBObjectStore()")
static IDBObjectStore create() {
throw new UnsupportedOperationException("Available only in JavaScript");
}
/**
* Returns true if the store has a key generator, and false otherwise.
*/
@JSProperty
boolean isAutoIncrement();
/**
* Returns a list of the names of indexes in the store.
*/
@JSProperty
DOMStringList getIndexNames();
/**
* Returns the key path of the store, or null if none.
*/
@JSProperty
Unknown getKeyPath();
/**
* Returns the name of the store.
*/
@JSProperty
String getName();
@JSProperty
void setName(String name);
/**
* Returns the associated transaction.
*/
@JSProperty
IDBTransaction getTransaction();
/**
* Adds or updates a record in store with the given value and key.
*
* If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.
*
* If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.
*
* If successful, request's result will be the record's key.
*/
IDBRequest add(Any value, IDBValidKey key);
IDBRequest add(Any value);
/**
* Deletes all records in store.
*
* If successful, request's result will be undefined.
*/
IDBRequest clear();
/**
* Retrieves the number of records matching the given key or key range in query.
*
* If successful, request's result will be the count.
*/
IDBRequest count(IDBValidKey key);
IDBRequest count(IDBKeyRange key);
IDBRequest count();
/**
* Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.
*
* Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
*/
IDBIndex createIndex(String name, String keyPath, IDBIndexParameters options);
IDBIndex createIndex(String name, StringIterable keyPath, IDBIndexParameters options);
IDBIndex createIndex(String name, String[] keyPath, IDBIndexParameters options);
IDBIndex createIndex(String name, String... keyPath);
/**
* Deletes records in store with the given key or in the given key range in query.
*
* If successful, request's result will be undefined.
*/
IDBRequest delete(IDBValidKey key);
IDBRequest delete(IDBKeyRange key);
/**
* Deletes the index in store with the given name.
*
* Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
*/
void deleteIndex(String name);
/**
* Retrieves the value of the first record matching the given key or key range in query.
*
* If successful, request's result will be the value, or undefined if there was no matching record.
*/
IDBRequest get(IDBValidKey query);
IDBRequest get(IDBKeyRange query);
/**
* Retrieves the values of the records matching the given key or key range in query (up to count if given).
*
* If successful, request's result will be an Array of the values.
*/
IDBRequest> getAll(@Nullable IDBValidKey query, int count);
IDBRequest> getAll(@Nullable IDBKeyRange query, int count);
IDBRequest> getAll(IDBValidKey query);
IDBRequest> getAll(IDBKeyRange query);
IDBRequest> getAll();
/**
* Retrieves the keys of records matching the given key or key range in query (up to count if given).
*
* If successful, request's result will be an Array of the keys.
*/
IDBRequest> getAllKeys(@Nullable IDBValidKey query, int count);
IDBRequest> getAllKeys(@Nullable IDBKeyRange query, int count);
IDBRequest> getAllKeys(IDBValidKey query);
IDBRequest> getAllKeys(IDBKeyRange query);
IDBRequest> getAllKeys();
/**
* Retrieves the key of the first record matching the given key or key range in query.
*
* If successful, request's result will be the key, or undefined if there was no matching record.
*/
IDBRequest getKey(IDBValidKey key);
IDBRequest getKey(IDBKeyRange key);
IDBIndex index(String name);
/**
* Opens a cursor over the records matching query, ordered by direction. If query is null, all records in store are matched.
*
* If successful, request's result will be an IDBCursorWithValue pointing at the first matching record, or null if there were no matching records.
*/
IDBRequest openCursor(@Nullable IDBValidKey query, IDBCursorDirection direction);
IDBRequest openCursor(@Nullable IDBKeyRange query, IDBCursorDirection direction);
IDBRequest openCursor(IDBValidKey query);
IDBRequest openCursor(IDBKeyRange query);
IDBRequest openCursor();
/**
* Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in store are matched.
*
* If successful, request's result will be an IDBCursor pointing at the first matching record, or null if there were no matching records.
*/
IDBRequest openKeyCursor(@Nullable IDBValidKey query, IDBCursorDirection direction);
IDBRequest openKeyCursor(@Nullable IDBKeyRange query, IDBCursorDirection direction);
IDBRequest openKeyCursor(IDBValidKey query);
IDBRequest openKeyCursor(IDBKeyRange query);
IDBRequest openKeyCursor();
/**
* Adds or updates a record in store with the given value and key.
*
* If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.
*
* If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.
*
* If successful, request's result will be the record's key.
*/
IDBRequest put(Any value, IDBValidKey key);
IDBRequest put(Any value);
}