@creasource/reactive-idb
Version:
A reactive wrapper to indexedDb using Rxjs
114 lines (113 loc) • 5.36 kB
TypeScript
import { Observable } from 'rxjs';
import { ReactiveIDBTransformer } from './reactive-idb-database';
import { ReactiveIDBIndex } from './reactive-idb-index';
import { ReactiveIDBTransaction } from './reactive-idb-transaction';
export declare class ReactiveIDBObjectStore<T = unknown> {
private readonly store;
readonly transaction: ReactiveIDBTransaction;
readonly transformer: ReactiveIDBTransformer<T>;
/**
* Returns true if the store has a key generator, and false otherwise.
*/
get autoIncrement(): boolean;
/**
* Returns a list of the names of indexes in the store.
*/
get indexNames(): DOMStringList;
/**
* Returns the key path of the store, or null if none.
*/
get keyPath(): null | string | string[];
/**
* Returns the name of the store.
*/
get name(): string;
/**
*
* @param store
* @param transaction
* @param transformer
*/
constructor(store: IDBObjectStore, transaction: ReactiveIDBTransaction, transformer?: ReactiveIDBTransformer<T>);
/**
* 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.
*/
add$(value: T, key?: IDBValidKey): Observable<IDBValidKey>;
/**
* Deletes all records in store.
*/
clear$(): Observable<undefined>;
/**
* Retrieves the number of records matching the given key or key range in query.
*/
count$(key?: IDBValidKey | IDBKeyRange): Observable<number>;
/**
* 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.
*/
/**
* Deletes records in store with the given key or in the given key range in query.
*
* If successful, request's result will be undefined.
*/
delete$(key: IDBValidKey | IDBKeyRange): Observable<undefined>;
/**
* Deletes the index in store with the given name.
*
* Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
*/
/**
* 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.
*/
get$(query: IDBValidKey | IDBKeyRange): Observable<T | undefined>;
/**
* 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.
*/
getAll$(query?: IDBValidKey | IDBKeyRange | null, count?: number): Observable<T[]>;
/**
* 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.
*/
getAllKeys$(query?: IDBValidKey | IDBKeyRange | null, count?: number): Observable<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.
*/
getKey$(query: IDBValidKey | IDBKeyRange): Observable<IDBValidKey | undefined>;
index(name: string): ReactiveIDBIndex<T>;
/**
* 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.
*/
openCursor$(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): Observable<IDBCursorWithValue | null>;
/**
* 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.
*/
openKeyCursor$(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): Observable<IDBCursor | null>;
/**
* 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.
*/
put$(value: T, key?: IDBValidKey): Observable<IDBValidKey>;
}