Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1x 1x 25x 25x 18x 7x 7x 7x | import type { Firestore } from 'firebase-admin/firestore'; import { FirestoreDocument } from './FirestoreDocument'; import type { FirestorePath } from '../../shared/firestore/FirestorePath'; export class FirestoreCollection< Documents extends Record<string, FirestoreDocument<any, any>> > { public constructor( private readonly firestore: Firestore, private readonly path: FirestorePath ) {} public document<Key extends keyof Documents & string>(key: Key): Documents[Key] { return new FirestoreDocument(this.firestore, this.path.appending(key)) as Documents[Key]; } public async remove(): Promise<void> { const collection = this.firestore.collection(this.path.fullPath); const documents = await collection.listDocuments(); await Promise.all(documents.map(async document => document.delete())); } } export namespace FirestoreCollection { export type DocumentsOf<Collection extends FirestoreCollection<any>> = Collection extends FirestoreCollection<infer Documents> ? Documents : never; } |