@creasource/reactive-idb
Version:
A reactive wrapper to indexedDb using Rxjs
65 lines (64 loc) • 2.84 kB
TypeScript
import { Observable } from 'rxjs';
import { ReactiveIDBObjectStore } from './reactive-idb-object-store';
export declare class ReactiveIDBIndex<T = unknown> {
private readonly index;
readonly objectStore: ReactiveIDBObjectStore<T>;
get keyPath(): string | string[];
get multiEntry(): boolean;
/**
* Returns the name of the index.
*/
get name(): string;
/**
*
*/
get unique(): boolean;
/**
*
* @param index
* @param objectStore The ReactiveIDBObjectStore this index belongs to.
*/
constructor(index: IDBIndex, objectStore: ReactiveIDBObjectStore<T>);
/**
* Retrieves the number of records matching the given key or key range in query.
*
* If successful, request's result will be the count.
*/
count$(key?: IDBValidKey | IDBKeyRange): Observable<number>;
/**
* 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$(key: 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$(key: IDBValidKey | IDBKeyRange): Observable<IDBValidKey | undefined>;
/**
* Opens a cursor over the records matching query, ordered by direction. If query is null, all records in index are matched.
*
* If successful, request's result will be an IDBCursorWithValue, 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 index are matched.
*
* If successful, request's result will be an IDBCursor, or null if there were no matching records.
*/
openKeyCursor$(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): Observable<IDBCursor | null>;
}