simplyfire
Version:
A lightweight firestore api for firebase cloud functions & Angular.
75 lines (74 loc) • 3.09 kB
TypeScript
import type { Firestore, DocumentChangeType, DocumentData, QuerySnapshot, SetOptions, Transaction } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
import { QueryBuilder, AbstractFirestoreApi } from '../db';
import * as i0 from "@angular/core";
export declare class FirestoreService extends AbstractFirestoreApi {
get firestore(): Firestore;
private cache;
collection<T = any>(path: string, qb?: QueryBuilder, maxAge?: number): Promise<T[]>;
collectionGroup<T = any>(collectionId: string, qb?: QueryBuilder, maxAge?: number): Promise<T[]>;
doc<T = any>(path: string, maxAge?: number): Promise<T>;
docRef(path: string): any;
upsert(collectionPath: string, data: {
[key: string]: any;
}, opts?: SetOptions): Promise<string>;
update(docPath: string, data: {
[key: string]: any;
}): Promise<void>;
delete(docPath: string): Promise<void>;
bulkUpsert(path: string, data: DocumentData[] | {
data: DocumentData;
qb?: QueryBuilder;
}, opts?: SetOptions): Promise<string[]>;
bulkDelete(path: string, qb?: QueryBuilder, maxSize?: number): Promise<string[]>;
/**
* write batch
*/
get batch(): any;
/**
* firestore timestamp
*/
get serverTimestamp(): import("@firebase/firestore").FieldValue;
/**
* FieldValue increment
*/
increment(n?: number): import("@firebase/firestore").FieldValue;
/**
* Returns a generated Firestore Document Id.
*/
createId(colPath?: string): string;
runTransaction(updateFunction: (transaction: Transaction | any) => Promise<unknown>): Promise<unknown>;
collectionValueChanges<T = any>(path: string, qb?: QueryBuilder): Observable<T[]>;
collectionGroupValueChanges<T = any>(collectionId: string, qb?: QueryBuilder): Observable<T[]>;
collectionSnapshot(path: string, qb?: QueryBuilder): Promise<QuerySnapshot<any> | any>;
collectionSnapshotChanges<T = any>(path: string, qb?: QueryBuilder, events?: DocumentChangeType[]): Observable<T[]>;
collectionGroupSnapshotChanges<T = any>(collectionId: string, qb?: QueryBuilder, events?: DocumentChangeType[]): Observable<T[]>;
docValueChanges<T = any>(path: string): Observable<T>;
/**
* @experimental
*
* Cache collection data in memory
*/
collectionWithCache<T = any>(path: string, qb?: QueryBuilder, maxAge?: number): Observable<T[]>;
/**
* @experimental
*
* Cache collectionGroup data in memory
*/
collectionGroupWithCache<T = any>(collectionId: string, qb?: QueryBuilder, maxAge?: number): Observable<T[]>;
/**
* @experimental
*
* Cache document data in memory
*/
docWithCache(path: string, maxAge?: number): Observable<any>;
/**
* @experimental
*
* Delete cached data from the memory
*/
deleteCache(path: string, qb?: QueryBuilder): boolean;
private fetchFromCache;
static ɵfac: i0.ɵɵFactoryDeclaration<FirestoreService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<FirestoreService>;
}