UNPKG

yalento

Version:

An awesome integration of Google Firebase for Angular and Node

67 lines (66 loc) 2.55 kB
import { Observable } from 'rxjs'; import { IEntity, Repository } from '../Repository'; import { AbstractConnector } from './AbstractConnector'; import { IConnectorInterface } from './ConnectorInterface'; export interface IConnectionLocalStorage { debug?: boolean; } export interface IStorage { /** * Get the name of the driver being used. * @returns Name of the driver */ readonly driver: string | null; /** * Get the value associated with the given key. * @param key the key to identify this value * @returns Returns a promise with the value of the given key */ get(key: string): Promise<any>; /** * Set the value for the given key. * @param key the key to identify this value * @param value the value for this key * @returns Returns a promise that resolves when the key and value are set */ set(key: string, value: any): Promise<any>; /** * Remove any value associated with this key. * @param key the key to identify this value * @returns Returns a promise that resolves when the value is removed */ remove(key: string): Promise<any>; /** * Clear the entire key value store. WARNING: HOT! * @returns Returns a promise that resolves when the store is cleared */ clear(): Promise<void>; /** * @returns Returns a promise that resolves with the number of keys stored. */ length(): Promise<number>; /** * @returns Returns a promise that resolves with the keys in the store. */ keys(): Promise<string[]>; /** * Iterate through each key,value pair. * @param iteratorCallback a callback of the form (value, key, iterationNumber) * @returns Returns a promise that resolves when the iteration has finished. */ forEach(iteratorCallback: (value: any, key: string, iterationNumber: number) => any): Promise<void>; } export declare class LocalStorageConnector<T> extends AbstractConnector<T> implements IConnectorInterface<IEntity<T>> { readonly options: IConnectionLocalStorage; private storage; private lastSql; constructor(repository: Repository<T>, storage: IStorage, options?: IConnectionLocalStorage); add(items: IEntity<T>[]): Promise<any>; remove(items: IEntity<T>[]): Promise<any>; update(items: IEntity<T>[]): Promise<any>; select(sql: string): void; selectOneByIdentifier(identifier: string): Promise<IEntity<T>>; disconnect(): void; getUserUuid(): Observable<string>; isPrivateMode(): boolean; }