UNPKG

firebase-lib-db

Version:

Database Lib to access Firestore (CRUD) and Cache Data

23 lines (18 loc) 857 B
import { firestore } from 'firebase-admin'; interface Database { Save: (collection: string, data: any) => Promise<string>; Update: (collection: string, id: string, data: any) => Promise<any>; FindOne: (collection: string, id: string) => Promise<any>; Delete: (collection: string, query: any) => Promise<any>; QueryData: (collection: string, query: any, order?: any, noCache?: boolean) => Promise<Array<any>>; } interface Cache { set(key: string, obj: any, ttl?: number): Promise<void>; get(key: string): Promise<any>; del(key: string): Promise<void>; delPattern(pattern: string): Promise<void>; getByPattern(pattern: string): Promise<any[]>; } declare function GetDatabase(firestore: firestore.Firestore): Database; declare function GetCache(): Cache; export { type Cache, type Database, GetCache, GetDatabase };