Interface IDBObjectStore
autoIncrement: boolean;
indexNames: DOMStringList;
keyPath: string | string[];
name: string;
transaction: IDBTransaction;
add(value: any, key?: IDBValidKey): IDBRequest<IDBValidKey>;
clear(): IDBRequest<undefined>;
count(query?: IDBValidKey | IDBKeyRange): IDBRequest<number>;
createIndex(name: string, keyPath: string | string[], options?: IDBIndexParameters): IDBIndex;
createIndex(name: string, keyPath: string | Iterable<string, any, any>, options?: IDBIndexParameters): IDBIndex;
delete(query: IDBValidKey | IDBKeyRange): IDBRequest<undefined>;
deleteIndex(name: string): void;
get(query: IDBValidKey | IDBKeyRange): IDBRequest<any>;
getAll(query?: IDBValidKey | IDBKeyRange, count?: number): IDBRequest<any[]>;
getAllKeys(query?: IDBValidKey | IDBKeyRange, count?: number): IDBRequest<IDBValidKey[]>;
getKey(query: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey>;
index(name: string): IDBIndex;
openCursor(query?: IDBValidKey | IDBKeyRange, direction?: IDBCursorDirection): IDBRequest<IDBCursorWithValue>;
openKeyCursor(query?: IDBValidKey | IDBKeyRange, direction?: IDBCursorDirection): IDBRequest<IDBCursor>;
put(value: any, key?: IDBValidKey): IDBRequest<IDBValidKey>;
}
Index
Properties
Readonly
autoIncrement
Readonly
indexNames
Returns a list of the names of indexes in the store.
Readonly
keyPath
Returns the key path of the store, or null if none.
name
Returns the name of the store.
Readonly
transaction
Returns the associated transaction.
Methods
add
- add(value, key?): IDBRequest<IDBValidKey>
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.
Parameters
- value: any
Optional
key: IDBValidKey
Returns IDBRequest<IDBValidKey>
clear
- clear(): IDBRequest<undefined>
Returns IDBRequest<undefined>
count
- count(query?): IDBRequest<number>
Retrieves the number of records matching the given key or key range in query.
If successful, request's result will be the count.
Parameters
Optional
query: IDBValidKey | IDBKeyRange
Returns IDBRequest<number>
createIndex
- create
Index (name, keyPath, options?): IDBIndex 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.
Parameters
- name: string
- keyPath: string | string[]
Optional
options: IDBIndexParameters
Returns IDBIndex
- create
Index (name, keyPath, options?): IDBIndex 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.
Parameters
- name: string
- keyPath: string | Iterable<string, any, any>
Optional
options: IDBIndexParameters
Returns IDBIndex
delete
- delete(query): IDBRequest<undefined>
Deletes records in store with the given key or in the given key range in query.
If successful, request's result will be undefined.
Parameters
- query: IDBValidKey | IDBKeyRange
Returns IDBRequest<undefined>
deleteIndex
get
- get(query): IDBRequest<any>
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.
Parameters
- query: IDBValidKey | IDBKeyRange
Returns IDBRequest<any>
getAll
- get
All (query?, count?): IDBRequest<any[]> 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.
Parameters
Optional
query: IDBValidKey | IDBKeyRangeOptional
count: number
Returns IDBRequest<any[]>
getAllKeys
- get
All (query?, count?): IDBRequest<IDBValidKey[]>Keys 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.
Parameters
Optional
query: IDBValidKey | IDBKeyRangeOptional
count: number
Returns IDBRequest<IDBValidKey[]>
getKey
- get
Key (query): IDBRequest<IDBValidKey> 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.
Parameters
- query: IDBValidKey | IDBKeyRange
Returns IDBRequest<IDBValidKey>
index
openCursor
- open
Cursor (query?, direction?): IDBRequest<IDBCursorWithValue> 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.
Parameters
Optional
query: IDBValidKey | IDBKeyRangeOptional
direction: IDBCursorDirection
Returns IDBRequest<IDBCursorWithValue>
openKeyCursor
- open
Key (query?, direction?): IDBRequest<IDBCursor>Cursor 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.
Parameters
Optional
query: IDBValidKey | IDBKeyRangeOptional
direction: IDBCursorDirection
Returns IDBRequest<IDBCursor>
put
- put(value, key?): IDBRequest<IDBValidKey>
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.
Parameters
- value: any
Optional
key: IDBValidKey
Returns IDBRequest<IDBValidKey>
Returns true if the store has a key generator, and false otherwise.
MDN Reference