import {Injectable, inject} from '@angular/core'; import {Observable} from 'rxjs'; import {shareReplay} from 'rxjs/operators'; import {DbService} from 'src/app/services/db.service'; import {GuestShow} from './guest-show'; @Injectable({ providedIn: 'root', }) export class GuestShowDataService { private dbService = inject(DbService); private collection = 'guest'; public list$: Observable = this.dbService.col$(this.collection).pipe( shareReplay({ bufferSize: 1, refCount: true, }) ); public read$: (id: string) => Observable = (id: string): Observable => this.dbService.doc$(`${this.collection}/${id}`); public update$: (id: string, data: Partial) => Promise = async (id: string, data: Partial): Promise => await this.dbService.doc(this.collection + '/' + id).update(data); public add: (data: Partial) => Promise = async (data: Partial): Promise => (await this.dbService.col(this.collection).add(data)).id; public delete: (id: string) => Promise = async (id: string): Promise => await this.dbService.doc(this.collection + '/' + id).delete(); }